Subodh Joshi
Subodh Joshi

Reputation: 13492

Git Push failed due to Change-Id

For me Git is creating error every single time when ever i am trying to push the code .With following command

git push origin HEAD:refs/for/master

So for temporary fix i have to use below command

 git commit --amend

then manually add the Change-Id as followed to this another Stackoverflow question,So this will allow to push the code.

But again if i will try to push any other code next time it will fail with the same error(Please have a look below)

Counting objects: 63, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (63/63), 5.94 KiB | 0 bytes/s, done.
Total 63 (delta 22), reused 28 (delta 4)
remote: Resolving deltas: 100% (22/22)
remote: Processing changes: refs: 1, done
remote: ERROR: [2a1ab5e] missing Change-Id in commit message footer
remote:
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 [email protected]:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote:
To ssh://gerrit.ext.net.google.com:29418/projectname/framework
 ! [remote rejected]   HEAD -> refs/for/master ([2a1ab5e] missing Change-Id in commit message footer)
error: failed to push some refs to 'ssh://gerrit.ext.net.google.com:29418/projectname/framework'

So i tried to add a hook like this

$ scp -p -P 29418 [email protected]:hooks/commit-msg  C:/GIT_Code_Base/unified-inventory/framework/framework/.git/hooks/
commit-msg                                    100% 4780    23.7KB/s   00:00

and again tried to push but end up with same error.

My question is that why every single time i have to add change-Id before the commit ? What is the permanent fix for this issue?

Upvotes: 1

Views: 1302

Answers (1)

The Gerrit message is self explanatory, just do the following:

1) Go to the local repository directory:

cd LOCAL-REPO-DIR

2) Install the commit-msg hook:

gitdir=$(git rev-parse --git-dir); scp -p -P 29418 [email protected]:hooks/commit-msg ${gitdir}/hooks/

3) Fix your current commit:

git commit --amend

Note 1: In step 3, you don't need to change anything in the commit, just run the "git commit --amend" command, save the commit message and exit. The Change-Id will be added automatically by the commit-msg hook. Execute "git log" to check that Change-Id was correctly added.

Note 2: From now on, everytime you create a commit the Change-Id will be added automatically by the commit-msg hook.

Upvotes: 2

Related Questions