Reputation: 4052
I have Gerrit set up to require change-id in the commit message footer. But, I was able to somehow push a change without a change-id in the footer. That seems to have messed up my branch (master branch). I am unable to push to the master branch now.
Here is what I've done so far:
> git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
> touch test.txt
> git add .
> git commit
> git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: test.txt
> git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v origin master:refs/for/master
Pushing to ssh://[email protected]:29418/project_name
To ssh://[email protected]:29418/project_name
! [rejected] master -> refs/for/master (non-fast-forward)
error: failed to push some refs to 'ssh://[email protected]:29418/project_name'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Completed with errors, see above
and here is the structure of the branches:
o [origin/master][origin/HEAD][master] current head
\ \
\ \
\ o commit without change-id in footer
\
o [origin/refs/for/master] test commit to try and fix previous
Upvotes: 1
Views: 735
Reputation: 22351
Let's divide your question in two topics:
Commit without the Change-Id
You have pushed the commit straight to branch bypassing Gerrit. This is accomplished by executing, for exemple, one of the following commands:
git push origin master:master
OR
git push origin master:refs/heads/master
When you push straight to branch, the Change-Id is not required because Gerrit was bypassed in the process. The only way to avoid this mistake is remove your permission to push to refs/heads/* (straight to branch).
Error pushing to refs/for/master
It seems that you have created, by mistake, a branch called "refs/for/master". I think this issue would happen if you, for example, executed a command like this:
git push origin master:refs/heads/refs/for/master
In this case, to fix the issue just remove the wrong branch using the Gerrit UI:
Upvotes: 2