简体   繁体   中英

Unable to push the code to the gerrit git repository

Our development setup is kind of:

user code ==> gerrit repository ==> DEV repository ==> INT repository

When I try to push my code to the gerrit repository the following error is thrown:

git/master% git push gerrit HEAD:refs/for/master


Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.05 KiB | 1.05 MiB/s, done.
Total 7 (delta 3), reused 3 (delta 0)
remote: Resolving deltas: 100% (3/3)
remote: Processing changes: refs: 1, done   
remote: ERROR: [1688e36] 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 use_abc@rbcm- 
gerrit.abc.mno.com:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:  git commit --amend
remote: 
To ssh://abcd.mno.com:29418/datacompiler/DataCompilerDevelopment
! [remote rejected]    HEAD -> refs/for/master ([1688e36] missing Change-Id 
in commit message footer)
 error: failed to push some refs to 'ssh://user_abc@mno- 
 gerrit.abc.mno.com:29418/datacompiler/DataCompilerDevelopment'

I understood from the error message that the issue is "[1688e36] missing Change-Id in commit message footer"

ie One of the old commit is missing Change-Id in it which is necessary while pushing to gerrit.

When I Googled I found that rebasing is the technique for correcting an old commit message. ( git amend is used for latest commit message modification. But in my case the message to be corrected is quite old)

When I tried performing rebasing I am losing other commits upon that commit.

 git rebase -i HEAD~5

 pick a09061420 commit message 1.
 pick 046316704 commit message 2.
 pick b5df179e7 commit message 3.
 pick b58fc9c41 commit message 4.
 pick 646bc8899 commit message 5.

I want to change commit message 4.

I have done the modification as below:

 pick a09061420 commit message 1.
 pick 046316704 commit message 2.
 pick b5df179e7 commit message 3.
 reword b58fc9c41 updated commit message 4.
 pick 646bc8899 commit message 5.

I have saved the file and pushed it. But I am losing the commits from 1-3.

Any help would be appreciated !

You will not loose any commits. However, commit id for commit-4 and commit-5(646bc8899) will be changed after you push your changes because you are making changes in commit4 hence its commit id will be changed and commit-4 is parant for commit-5 hence its id will also be changed.

I also feel that it is not as it is screenshot of what you are seeing because you are executing it with HEAD~10 and result contains only 5 commits wheras you should see 10 commits. If 10 commits do not exist then you will get error. So all commits after commit4 will have a new id with same content.

For example before rebase if it was like -

pick b4e6a4d commit message 1.
pick cf8782b commit message 2.
pick c05b513 commit message 3.
pick 4966621 commit message 4.
pick f4297e7 commit message 5.
pick 48eaf3e commit message 6.

and you changed it to:

pick b4e6a4d commit message 1.
pick cf8782b commit message 2.
reword c05b513 message changed from commit message 3.
pick 4966621 commit message 4.
pick f4297e7 commit message 5.
pick 48eaf3e commit message 6.

It will result in following after push:

b4e6a4d commit message 1.
cf8782b commit message 2.
f42f02f message changed from commit message 3.
f8a49c4 commit message 4.
3f4e71e commit message 5.
81f5af5 commit message 6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM