jmbejara / comp-econ-sp19

Main Course Repository for Computational Methods in Economics (Econ 21410, Spring 2019)
48 stars 26 forks source link

General Question about GitKraken/Git #4

Open henryli78 opened 5 years ago

henryli78 commented 5 years ago

For class exercises (such as the portfolio_optimization) I have been just opening up the .ipynb file from the comp-econ-sp19 copy I made on my laptop. After saving my file, GitKraken labels this as a WIP.

I don't want to mess up the class's general central file (i.e. the one in the master copy) but I also want to get rid of the "WIP" in GitKraken without deleting my solution for portfolio_optimization.

Should I be staging my files without commiting? Or commiting without pushing? Or just copy the files to my own repository and save them there? Is there something convenient in Git that I can do/what would be the right thing to do in this case?

Thanks in advance.

jmbejara commented 5 years ago

Good question. The easiest approach would be to save your edited files to some other place so that you can keep your clone of the class repo "clean." This will allow you to pull changes from it without ever having to worry about merge conflicts.

If you're feeling adventurous and want to explore the features of Git, you can commit your personal changes (the process to do this is to stage your changes and then commit them). If you ever encounter merge conflicts---hopefully this will be a rare occurrence---I can help you deal with them. At that point, you might consider using branches to track the divergent histories of your version of the repo and the class version. You can read more about branching here:

Note that as long as you have committed your changes, you will always have a backup of what you've done. Creating a commit is like taking a snapshot or backup of all of your files in your repo. If you ever need to, you can always recover your files from the point in time in which any commit was created. (Staging and commiting tells Git to include changed/WIP files in the next commit. Changes not included will not be backed up.)

henryli78 commented 5 years ago

Thanks for the response!

So I can commit the file, but not push it right? This way I have the backup through Git and it is on my computer, but because I never pushed it won't affect the master repo.

jmbejara commented 5 years ago

@henryli78 That's right. You won't be able to push to it. jmbejara/comp-econ-sp19 is a remote repo that you don't have "write permission" for.

However, as an FYI, repos can have multiple "remote repos" associated with them. You could create a separate repo on GitHub, add a second remote repo to your local repo (the clone on your laptop), and then you could push to that repo. You would then pull jmbejara/comp-econ-sp19 on a regular basis and then push changes to, e.g., henryli78/comp-econ-sp19. Here's some reference material:

henryli78 commented 5 years ago

Thanks so much! I will look into this.