I have many commits. But my last commit have not Change-Id. An can not push to Gerrit.
How to add Change-Id to previous commit?
Gerrit provides a commit-msg
hook script that will automatically add change-ids to your commits.
The documentation to which I linked provides instructions for installing it:
To obtain the commit-msg script use scp, wget or curl to download it to your local system from your Gerrit server.
You can use either of the below commands:
$ scp -p -P 29418 <your username>@<your Gerrit review server>:hooks/commit-msg <local path to your git>/.git/hooks/ $ curl -Lo <local path to your git>/.git/hooks/commit-msg <your Gerrit http URL>/tools/hooks/commit-msg
Once you've installed the commit-msg
hook, you can use git commit --amend
to update your commit message; when you save it, the hook will add the Change-Id
to the message.