Non-fast Forward Error When Pushing For Code Review

899 views
Skip to first unread message

Ryan Alberts

unread,
Apr 27, 2009, 9:27:29 AM4/27/09
to Repo and Gerrit Discussion, awar...@gmail.com
I am kind of stuck in a pickle and not quite sure what to do next...

git push for-code-review
To ssh://cainteg@ah-git:29418/ClientArchitecture
! [rejected] HEAD -> refs/for/master (non-fast forward)
error: failed to push some refs to 'ssh://cainteg@ah-git:29418/
ClientArchitecture'

When anyone tries to push for code review they are getting the above
error. Unfortunately, I do not see anything being logged in Jetty.

The funny thing is that I am able to "git push origin master" which
bypasses the code review but still uses Gerrit's ssh port.

Any recommendations on things I can check?

Thing I have tried:
- Restarted Jetty
- Gave broader permissions in git repo
- Checked logs

Not sure if this helps but this is our git config...

[remote "origin"]
url = ssh://cainteg@ah-git:29418/ClientArchitecture
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "for-code-review"]
url = ssh://cainteg@ah-git:29418/ClientArchitecture
push = HEAD:refs/for/master
[user]
name = Ryan Alberts
email = ralb...@gmail.com
[branch "master"]
remote = origin
merge = refs/heads/master
rebase = true
[branch]
autosetupmerge = true

Shawn Pearce

unread,
Apr 27, 2009, 10:11:40 AM4/27/09
to repo-d...@googlegroups.com, awar...@gmail.com
On Mon, Apr 27, 2009 at 06:27, Ryan Alberts <ralb...@gmail.com> wrote:

I am kind of stuck in a pickle and not quite sure what to do next...

git push for-code-review
To ssh://cainteg@ah-git:29418/ClientArchitecture
 ! [rejected]        HEAD -> refs/for/master (non-fast forward)
error: failed to push some refs to 'ssh://cainteg@ah-git:29418/
ClientArchitecture'

Sounds to me like the repository has a refs/for/master branch actually *in* the repository.  The fact that the branch exists is overriding Gerrit's magic handling of this ref.

The way that happened is, someone probably pushed to the repository over a non-Gerrit port (e.g. through Gitosis), but pushed to refs/for/master instead of refs/heads/master, and Git dutifully created the ref the user asked it to create.

Delete the ref with

  git --git-dir=...basepath/ClientArchitecture.git update-ref -d refs/for/master refs/for/master^0

Then try uploading for review again.

You shouldn't need to restart Gerrit after the ref delete; Gerrit handles ref changes automatically, just not new packs being introduced.  Though I have patches for that that I'm starting to load test.  Maybe by next week they'll be ready for use.

Ryan Alberts

unread,
Apr 27, 2009, 12:18:21 PM4/27/09
to Repo and Gerrit Discussion
Shawn -

You are seriously a genius! Thank you so much!

Note to self: I think I need to start being more restrictive on access
so that these things will not accidentally happen.


On Apr 27, 9:11 am, Shawn Pearce <s...@google.com> wrote:

Shawn Pearce

unread,
Apr 27, 2009, 12:23:17 PM4/27/09
to repo-d...@googlegroups.com
On Mon, Apr 27, 2009 at 09:18, Ryan Alberts <ralb...@gmail.com> wrote:

Note to self: I think I need to start being more restrictive on access
so that these things will not accidentally happen.

That's why at Google we only use Gerrit access to the repositories.  No anonymous git.  No SSH on the standard port 22.   No local filesystem access.  100% Gerrit over 29418.  Harder for a user to make a mistake when Gerrit is in the middle and checking everything that flows through.

:-)
Reply all
Reply to author
Forward
0 new messages