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 | = Push fails due to commit message |
Edwin Kempin | c7f9e45 | 2010-12-27 09:21:45 +0100 | [diff] [blame] | 3 | |
| 4 | If Gerrit rejects pushing a commit it is often the case that there is |
| 5 | an issue with the commit message of the pushed commit. In this case |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 6 | the problem can often be resolved by fixing the commit message. |
Edwin Kempin | c7f9e45 | 2010-12-27 09:21:45 +0100 | [diff] [blame] | 7 | |
| 8 | If the commit message of the last commit needs to be fixed you can |
| 9 | simply amend the last commit (please find a detailed description in |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 10 | the link:http://www.kernel.org/pub/software/scm/git/docs/git-commit.html[Git documentation,role=external,window=_blank]): |
Edwin Kempin | c7f9e45 | 2010-12-27 09:21:45 +0100 | [diff] [blame] | 11 | |
| 12 | ---- |
| 13 | $ git commit --amend |
| 14 | ---- |
| 15 | |
| 16 | If you need to fix the commit messages of several commits or of any |
| 17 | commit other than the last one you have to do an interactive git |
| 18 | rebase for the affected commits. While doing the interactive rebase |
| 19 | you can e.g. choose 'reword' for those commits for which you want to |
| 20 | fix the commit messages. For a detailed description of git rebase |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 21 | please check the link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[Git documentation,role=external,window=_blank]. |
Edwin Kempin | c7f9e45 | 2010-12-27 09:21:45 +0100 | [diff] [blame] | 22 | |
| 23 | Please use interactive git rebase with care as it rewrites existing |
| 24 | commits. Generally you should never rewrite commits that have already |
| 25 | been submitted in Gerrit. |
| 26 | |
| 27 | [[commit_hooks]] |
| 28 | Sometimes commit hooks are used to automatically insert/update |
| 29 | information in the commit message. If such information is missing in |
| 30 | the commit message of existing commits (e.g. because the commit hook |
| 31 | was only configured later) rewriting the commits will (re)execute the |
| 32 | commit hook and so update the commit messages. If you do an |
| 33 | interactive rebase to achieve this make sure that the affected |
| 34 | commits are really rewritten, e.g. by choosing 'reword' for all these |
| 35 | commits and then confirming all the commit messages. Just picking a |
| 36 | commit may not rewrite it. |
| 37 | |
| 38 | |
| 39 | GERRIT |
| 40 | ------ |
| 41 | Part of link:error-messages.html[Gerrit Error Messages] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 42 | |
| 43 | SEARCHBOX |
| 44 | --------- |