Save all files you have open in an editor. Check if you have any uncommitted changes:
git status
If it says nothing to commit
, then you don't need to do a commit. If it says
Changes not staged for commit
, then you need to commit your changes:
git commit -a -m "describe your changes here"
Next, you need to pull our changes to your local git repository. To do this, first add our github repository as a git remote:
git remote add upstream https://github.com/iloveponies/<current-chapter>.git
Make sure to use the correct chapters repository! Now we can pull the changes into the local repository:
git pull upstream master
If all went fine, an editor will open with an autogenerated merge-commit
message. Save and close this file (if this opened Vim for you and you're not
familiar with it, you can save and exit by typing :x
and pressing enter).
If you got a merge conflict, you need to do the following:
-
First, check which files have conflicts:
git status
-
For each `file` listed under `Unmerged paths`, do the following unless the
`file` is under `src`:
git checkout --theirs file
-
And the following for the files under `src` (if any):
git checkout --ours file
-
Finally, commit this merge:
git commit -a -m "merged upstream"
Now your local repository has been updated. To update your remote github repository as well, run:
git push
And you are done.
If you encountered some problems that you couldn't fix during the previous steps, you can always clone you github repository again. First rename your old clone, then clone again. As the first thing in the new clone, add our github repository as a remote like before:
git remote add upstream https://github.com/iloveponies/<current-chapter>.git
Make sure you have a copy of your answers to the exercises somewhere else! Then run the following:
git fetch upstream
git reset --hard upstream/master
git push --force
After this, you can copy your answers into this repository and continue working in here.