0

i have a git repository where i have create one project. There are already some existing projects which are working fine.

Now i want to push the code of this new project, i have added the gerrit change-id in the commit but still i am getting the following error when trying to push. I am using egit( eclipse git) as a git client

 missing Change-Id in commit message footer
Processing changes: refs: 1
Processing changes: refs: 1, done    
ERROR: missing Change-Id in commit message footer

Hint: To automatically insert Change-Id, install the hook:
  gitdir=$(git rev-parse --git-dir); scp -p -P 29418 i054564@git.wdf.sap.corp:hooks/commit-msg ${gitdir}/hooks/
And then amend the commit:
  git commit --amend

Is there any configuration to be done when i added a new project to an existing git repo for gerrit ?

saurav
  • 4,032
  • 7
  • 38
  • 74

2 Answers2

2

It seems that you're trying to push more than one commit to Gerrit but only the last one has the Change-Id. When you push a commit to Gerrit, all parent commits that don't exist yet in Gerrit will be pushed too. Take a look at the Git log to check all commits that will be pushed.

1

I'll make some additional remarks to Marcelo's answer.

Suppose the commit history is A-B-C-D. C and D are your newly made commits. If either C or D has no change-id, the push is blocked. In this case, you need to rewrite the commit message of C and D(let's say neither have change-id) before another push.

Install the hook first as the error log says.

gitdir=$(git rev-parse --git-dir); scp -p -P 29418 i054564@git.wdf.sap.corp:hooks/commit-msg ${gitdir}/hooks/

Run git log to check the commits.

Rewrite the commit messages.

git reset B --hard
git cherry-pick C
git commit --amend
#simply save and quit
git cherry-pick D
git commit --amend
#simply save and quit.

If there is an existing change-id, you could delete the whole change-id line, save and quit so that commit-msg generates a new change-id. In some cases you may need it.

In order to automatically deploy the hook commit-msg for every clone, you could add this commit-msg into Git's TEMPLATE DIRECTORY. After this copy, you could run git init in an existing repo as an alternative method of copying the commit-msg into it.

Since you are using Gerrit, I'd like to say more. A merge-commit does not provoke the hook commit-msg, so a local true merge won't have change-id either even if the hook has been deployed. This will block the push too. So don't use git pull origin <branch> to sync and update the local branch before a push. Either git pull origin --rebase <branch> or git fetch origin <branch> && git rebase FETCH_HEAD is better. This makes no merge commit in the local.

ElpieKay
  • 19,185
  • 5
  • 22
  • 36