blob: b6aad6979e62d266389ad60b92c4d8d850f4a459 [file] [log] [blame]
Sven Selberg183b4fa2016-04-08 13:58:38 +02001= same Change-Id in multiple changes
Edwin Kempinefb5f9a2010-12-16 11:02:00 +01002
3With this error message Gerrit rejects to push a commit if it
David Pursehouse2c6f6382014-09-04 13:06:19 +09004contains the same Change-Id as a predecessor commit.
Edwin Kempinefb5f9a2010-12-16 11:02:00 +01005
6The reason for rejecting such a commit is that it would introduce, for
7the corresponding change in Gerrit, a dependency upon itself. Gerrit
8prevents such dependencies between patch sets within the same change
9to keep the review process simple. Otherwise reviewers would not only
10have to review the latest patch set but also all the patch sets the
David Pursehouse221d4f62012-06-08 17:38:08 +090011latest one depends on.
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010012
13This error is quite common, it appears when a user tries to address
14review comments and creates a new commit instead of amending the
15existing commit. Another possibility for this error, although less
16likely, is that the user tried to create a patch series with multiple
David Pursehouse2c6f6382014-09-04 13:06:19 +090017changes to be reviewed and accidentally included the same Change-Id
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010018into the different commit messages.
19
20
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080021== Example
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010022
23Here an example about how the push is failing. Please note that the
24two commits 'one commit' and 'another commit' both have the same
David Pursehouse2c6f6382014-09-04 13:06:19 +090025Change-Id (of course in real life it can happen that there are more
26than two commits that have the same Change-Id).
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010027
28----
29 $ git log
30 commit 13d381265ffff88088e1af88d0e2c2c1143743cd
31 Author: John Doe <john.doe@example.com>
32 Date: Thu Dec 16 10:15:48 2010 +0100
33
34 another commit
35
36 Change-Id: I93478acac09965af91f03c82e55346214811ac79
37
38 commit ca45e125145b12fe9681864b123bc9daea501bf7
39 Author: John Doe <john.doe@example.com>
40 Date: Thu Dec 16 10:12:54 2010 +0100
41
42 one commit
43
44 Change-Id: I93478acac09965af91f03c82e55346214811ac79
45
46 $ git push ssh://JohnDoe@host:29418/myProject HEAD:refs/for/master
47 Counting objects: 8, done.
48 Delta compression using up to 2 threads.
49 Compressing objects: 100% (2/2), done.
50 Writing objects: 100% (6/6), 558 bytes, done.
51 Total 6 (delta 0), reused 0 (delta 0)
52 To ssh://JohnDoe@host:29418/myProject
Sven Selberg183b4fa2016-04-08 13:58:38 +020053 ! [remote rejected] HEAD -> refs/for/master (same Change-Id in multiple changes.
54 Squash the commits with the same Change-Id or ensure Change-Ids are unique for each commit)
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010055 error: failed to push some refs to 'ssh://JohnDoe@host:29418/myProject'
Sven Selberg183b4fa2016-04-08 13:58:38 +020056
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010057----
58
David Pursehousea43ad9c2014-09-04 13:15:15 +090059If it was the intention to rework a change and push a new patch
60set, the problem can be fixed by squashing the commits that contain the
David Pursehouse2c6f6382014-09-04 13:06:19 +090061same Change-Id. The squashed commit can then be pushed to Gerrit.
David Pursehousea43ad9c2014-09-04 13:15:15 +090062
63To squash the commits, use `git rebase -i` to do an interactive rebase. For
64the example above where the last two commits have the same Change-Id,
Edwin Kempinefb5f9a2010-12-16 11:02:00 +010065this means an interactive rebase for the last two commits should be
66done. For further details about the git rebase command please check
67the link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[Git documentation for rebase].
68
69----
70 $ git rebase -i HEAD~2
71
72 pick ca45e12 one commit
73 squash 13d3812 another commit
74
75 [detached HEAD ab37207] squashed commit
76 1 files changed, 3 insertions(+), 0 deletions(-)
77 Successfully rebased and updated refs/heads/master.
78
79 $ git log
80 commit ab37207d33647685801dba36cb4fd51f3eb73507
81 Author: John Doe <john.doe@example.com>
82 Date: Thu Dec 16 10:12:54 2010 +0100
83
84 squashed commit
85
86 Change-Id: I93478acac09965af91f03c82e55346214811ac79
87
88 $ git push ssh://JohnDoe@host:29418/myProject HEAD:refs/for/master
89 Counting objects: 5, done.
90 Writing objects: 100% (3/3), 307 bytes, done.
91 Total 3 (delta 0), reused 0 (delta 0)
92 To ssh://JohnDoe@host:29418/myProject
93 * [new branch] HEAD -> refs/for/master
94----
95
96If it was the intention to create a patch series with multiple
David Pursehouse221d4f62012-06-08 17:38:08 +090097changes to be reviewed, each commit message should contain the
David Pursehouse2c6f6382014-09-04 13:06:19 +090098Change-Id of the corresponding change in Gerrit. If a change in
99Gerrit does not exist yet, the Change-Id should be generated (either
100by using a link:cmd-hook-commit-msg.html[commit hook] or by using EGit) or the Change-Id could be
Edwin Kempinefb5f9a2010-12-16 11:02:00 +0100101removed (not recommended since then amending this commit to create
David Pursehouse2c6f6382014-09-04 13:06:19 +0900102subsequent patch sets is more error prone). To change the Change-Id
Edwin Kempinefb5f9a2010-12-16 11:02:00 +0100103of an existing commit do an interactive link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[git rebase] and fix the
104affected commit messages.
105
106
107GERRIT
108------
109Part of link:error-messages.html[Gerrit Error Messages]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700110
111SEARCHBOX
112---------