0

When trying to upload my changes to gerrit with git review I am getting this error message:

Fetching gerrit
2018-01-26 13:33:52.161429 Running: git rev-parse HEAD
2018-01-26 13:33:52.166465 Running: git show-ref --quiet --verify refs/remotes/gerrit/master
2018-01-26 13:33:52.172314 Running: git rebase -p -i remotes/gerrit/master
2018-01-26 13:33:53.075322 Running: git reset --hard b8fb53d42c568aaed3216758076b5a5d2df6ebc6
2018-01-26 13:33:53.086334 Running: git config --get-colorbool color.review true
2018-01-26 13:33:53.091360 Running: git log --color=always --decorate --oneline HEAD --not --remotes=gerrit
2018-01-26 13:33:53.098427 Running: git rev-parse --symbolic-full-name --abbrev-ref HEAD
2018-01-26 13:33:53.105430 Running: git log --pretty='%B' HEAD^1..HEAD
Using local branch name "master" for the topic of the change submitted
2018-01-26 13:33:53.113735 Running: git push gerrit HEAD:refs/publish/master
fatal: One or more refs/publish/ names blocks change upload
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

My ssh key works; I can ssh clone projects from gerrit without errors; and git review -s is working correctly. My git config:

remote.origin.url=git@gitlab.test.lt:tt-java/service-client.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
remote.gerrit.url=ssh://test.test@review.test.lt:29418/service-client.git
remote.gerrit.fetch=+refs/heads/*:refs/remotes/gerrit/*

gerrit  ssh://test.test@review.test.lt:29418/service-client.git (fetch)
gerrit  ssh://test.test@review.test.lt:29418/service-client.git (push)
origin  git@gitlab.test.lt:tt-java/service-client.git (fetch)
origin  git@gitlab.test.lt:tt-java/service-client.git (push)

git review was installed via homebrew on osx. I've read about publishing to refs/for/master, but gettings same error. Any ideas what is wrong here?

4

1 回答 1

3

refs/publish vs refs/for

refs/publish/* is just an alternative name for refs/for/* - there's no difference using one of them.

The issue

Your server repository has a branch under the refs/for/ namespace. Gerrit refuses to work when this happens because now refs/for/ (which normally is a "magical" branch) is actually a real branch in the Git repository.

This branch was probably created, by mistake, for a user pushing directly to the Git repository rather than to the Gerrit SSH port.

How to fix

To see which refs already exist, the Gerrit administrator needs to go to that specific repository and execute:

git for-each-ref refs/for

He needs to delete all of those refs or rename them to a different name. Normally it's safe to just remove all of them executing the following:

for n in $(git for-each-ref --format='%(refname)' refs/for); do git
update-ref -d $n; done

More info

See here.

于 2018-01-26T12:39:17.307 回答