Commit | Line | Data |
---|---|---|
0328019d PG |
1 | |
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 | |
4 | forward. | |
5 | ||
6 | If you type git status you should see something like this. | |
7 | ||
8 | # On branch master | |
9 | # Your branch and 'origin/master' have diverged, | |
10 | # and have 2 and 2 different commit(s) each, respectively. | |
11 | # | |
12 | nothing to commit (working directory clean) | |
13 | ||
14 | This means that the history of the repository looks something like this | |
15 | ||
16 | C---D master | |
17 | / | |
18 | A---B---E---F origin/master | |
19 | ||
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. | |
22 | ||
23 | There are two ways to fix this. One you could do a merge which results in this | |
24 | ||
25 | C---D---- | |
26 | / \ | |
27 | A---B---E---F---M master, origin/master | |
28 | ||
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. | |
31 | ||
32 | Options two is to do a rebase which results in this | |
33 | ||
34 | C'--D' master | |
35 | / | |
36 | A---B---E---F origin/master | |
37 | ||
38 | Where C' and D' are the same commits as before, with the exception of having to | |
39 | handle possible collisions. | |
40 | ||
41 | This is what we'll be doing. To perform this operation simply type | |
42 | ||
43 | > git rebase origin/master master | |
44 | ||
45 | or if you are on the branch master, you can simply use | |
46 | ||
47 | > git rebase origin/master | |
48 | ||
49 | If there are no collisions, your done. Here's some example output. | |
50 | ||
51 | First, rewinding head to replay your work on top of it... | |
52 | Applying: commit C's message | |
53 | Applying: commit D's message | |
54 | ||
55 | If there are collisions, you have to resolve them. Once resolved you | |
56 | ||
57 | > git add file | |
58 | > git rebase --continue | |
59 | ||
60 | and it continues rebaseing your changes. If you want to abort the rebase | |
61 | because the resolve was too nasty you can | |
62 | ||
63 | > git rebase --abort | |
64 | ||
65 | which will bring you back to | |
66 | ||
67 | C---D master | |
68 | / | |
69 | A---B---E---F origin/master | |
70 | ||
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 ... | |
73 | ||
74 | Enjoy, | |
75 | Patrik |