2 So, you want to push something but you are getting a non-fast forward error.
3 Here's how to update your local repository so your push will be a fast
6 If you type git status you should see something like this.
9 # Your branch and 'origin/master' have diverged,
10 # and have 2 and 2 different commit(s) each, respectively.
12 nothing to commit (working directory clean)
14 This means that the history of the repository looks something like this
18 A---B---E---F origin/master
20 Where C and D are two commits you made, and E and F are two commits someone
21 else made and pushed to the up stream repository.
23 There are two ways to fix this. One you could do a merge which results in this
27 A---B---E---F---M master, origin/master
29 Where M is a merge commit of master and origin/master, and when you push the
30 history will literally have this small loop in it. We will _NOT_ be doing this.
32 Options two is to do a rebase which results in this
36 A---B---E---F origin/master
38 Where C' and D' are the same commits as before, with the exception of having to
39 handle possible collisions.
41 This is what we'll be doing. To perform this operation simply type
43 > git rebase origin/master master
45 or if you are on the branch master, you can simply use
47 > git rebase origin/master
49 If there are no collisions, your done. Here's some example output.
51 First, rewinding head to replay your work on top of it...
52 Applying: commit C's message
53 Applying: commit D's message
55 If there are collisions, you have to resolve them. Once resolved you
58 > git rebase --continue
60 and it continues rebaseing your changes. If you want to abort the rebase
61 because the resolve was too nasty you can
65 which will bring you back to
69 A---B---E---F origin/master
71 once your done rebaseing you can simply do a git push and it should work out
72 now. Assuming of course that someone else didn't push more stuff ...