I'm currently in a course where the professor intermittently releases assignments on a public repo. I have this repo cloned on my computer, but I don't know how to go about getting the newly released assignments.
Essentially, I want to pull the new files without deleting my work on the old files which I have edited. Do I create a fork? If so, how do I pull changes from upstream but also keep my changes? How do I resolve the conflicts that will occur when my versions of assignments have been edited? Etc.
Any help is greatly appreciated because, as of now, I've just been moving all of my files and then completely re-downloading the updated repo.
Also, I'm using GitHub desktop
I'm unfamiliar with GitHub Desktop, but hopefully there are simple equivalents in the GUI for these commands. If not, you can try with a backup branch in Git Bash (the command line).
First, stage and commit your changes by doing git add file1 file2
etc. followed by git commit -m "change x"
Then, here are a few possible options to update your current branch:
git pull origin master
will first fetch the content from the remote and then merge it to your current branch. If you end up with merge conflicts, git will tell you how to proceed. You can resolve conflicts in your editor or GitHub Desktop. For this reason, you may end up with a merge commit.git pull --ff-only
will do the above, but it's safer in that it won't create a merge commit. It only updates your local master if the history is linear and it can be fast-forwarded (hence the ff-only).When in doubt, create a backup branch of your current branch with git checkout -b my-backup
before trying anything :)