Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 1 | non-fast forward |
| 2 | ================ |
| 3 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 4 | With this error message Gerrit rejects a push if the remote branch can't |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 5 | be fast forwarded onto the pushed commit. This is the case if the |
| 6 | pushed commit is not based on the current tip of the remote branch. |
| 7 | |
| 8 | If a non-fast forward update would be done, all commits from the |
| 9 | remote branch that succeed the base commit of the pushed commit would |
| 10 | be removed. This would be especially confusing for other users that |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 11 | have based their work on such a commit. Because of this Git by |
| 12 | default does not allow non-fast forward updates. |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 13 | |
| 14 | When working with Gerrit, this error can only occur if |
| 15 | link:user-upload.html#bypass_review[code review is bypassed]. |
| 16 | |
| 17 | There are different reasons why this error can occur: |
Edwin Kempin | ddfc41a | 2011-05-06 10:32:05 +0200 | [diff] [blame] | 18 | |
| 19 | . the remote branch has evolved since you started your development |
| 20 | . you are pushing the commit to the wrong project |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 21 | |
| 22 | |
| 23 | the remote branch has evolved since you started your development |
| 24 | ---------------------------------------------------------------- |
| 25 | |
| 26 | You start your development based on the current tip of the remote |
| 27 | branch. While you implement your feature / bug-fix, a change in Gerrit |
| 28 | gets submitted (or another user directly pushes a commit) so that the |
| 29 | remote branch evolves. If you are now pushing your commit, with |
| 30 | bypassing code review, your push will be rejected with the error |
| 31 | message 'non-fast forward'. To solve the problem you have to either |
Edwin Kempin | ddfc41a | 2011-05-06 10:32:05 +0200 | [diff] [blame] | 32 | |
| 33 | . link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[rebase] your commit on the new tip of the remote branch or |
| 34 | . link:http://www.kernel.org/pub/software/scm/git/docs/git-merge.html[merge] your commit with the new tip of the remote branch. |
| 35 | |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 36 | Afterwards the push should be successful. |
| 37 | |
| 38 | |
| 39 | you are pushing the commit to the wrong project |
| 40 | ----------------------------------------------- |
| 41 | |
| 42 | If you do a commit in one project and then accidentally push this |
| 43 | commit, with bypassing code review, to another project, this will fail |
| 44 | with the error message 'non-fast forward'. To fix the problem you |
| 45 | should check the push specification and verify that you are pushing |
| 46 | the commit to the correct project. |
| 47 | |
| 48 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 49 | Although it is considered bad practice, it is possible to allow |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 50 | non-fast forward updates with Git. For this the remote Git repository |
| 51 | has to be configured to not deny non-fast forward updates (set the |
| 52 | link:http://www.kernel.org/pub/software/scm/git/docs/git-config.html[Git configuration] parameter 'receive.denyNonFastForwards' to |
| 53 | 'false'). Then it is possible to push a non-fast forward update by |
| 54 | using the '--force' option. |
| 55 | |
| 56 | |
| 57 | GERRIT |
| 58 | ------ |
| 59 | Part of link:error-messages.html[Gerrit Error Messages] |