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