Marian Harbach | ebeb154 | 2019-12-13 10:42:46 +0100 | [diff] [blame] | 1 | :linkattrs: |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 2 | = non-fast forward |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 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 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 23 | == the remote branch has evolved since you started your development |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 24 | |
| 25 | You start your development based on the current tip of the remote |
| 26 | branch. While you implement your feature / bug-fix, a change in Gerrit |
| 27 | gets submitted (or another user directly pushes a commit) so that the |
| 28 | remote branch evolves. If you are now pushing your commit, with |
| 29 | bypassing code review, your push will be rejected with the error |
| 30 | message 'non-fast forward'. To solve the problem you have to either |
Edwin Kempin | ddfc41a | 2011-05-06 10:32:05 +0200 | [diff] [blame] | 31 | |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 32 | . link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[rebase,role=external,window=_blank] your commit on the new tip of the remote branch or |
| 33 | . link:http://www.kernel.org/pub/software/scm/git/docs/git-merge.html[merge,role=external,window=_blank] your commit with the new tip of the remote branch. |
Edwin Kempin | ddfc41a | 2011-05-06 10:32:05 +0200 | [diff] [blame] | 34 | |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 35 | Afterwards the push should be successful. |
| 36 | |
| 37 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 38 | == you are pushing the commit to the wrong project |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 39 | |
| 40 | If you do a commit in one project and then accidentally push this |
| 41 | commit, with bypassing code review, to another project, this will fail |
| 42 | with the error message 'non-fast forward'. To fix the problem you |
| 43 | should check the push specification and verify that you are pushing |
| 44 | the commit to the correct project. |
| 45 | |
| 46 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 47 | Although it is considered bad practice, it is possible to allow |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 48 | non-fast forward updates with Git. For this the remote Git repository |
| 49 | has to be configured to not deny non-fast forward updates (set the |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 50 | link:http://www.kernel.org/pub/software/scm/git/docs/git-config.html[Git configuration,role=external,window=_blank] parameter 'receive.denyNonFastForwards' to |
Edwin Kempin | d54ccbd | 2011-02-07 11:47:05 +0100 | [diff] [blame] | 51 | 'false'). Then it is possible to push a non-fast forward update by |
| 52 | using the '--force' option. |
| 53 | |
| 54 | |
| 55 | GERRIT |
| 56 | ------ |
| 57 | Part of link:error-messages.html[Gerrit Error Messages] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 58 | |
| 59 | SEARCHBOX |
| 60 | --------- |