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