我试图了解git和gerrit几天,并且有一些错误,我找不到合适的解决方案。这是错误消息;
*asfaa@asadaf:~/test$ git review -R
Could not connect to gerrit.
Enter your gerrit username: remote0
Trying again with ssh://<username>@<ip>:29418/test
Creating a git remote called "gerrit" that maps to:
ssh://<username>@<ip>:29418/test
This repository is now set up for use with git-review. You can set the
default username for future repositories with:
git config --global --add gitreview.username "remote0"
Your change was committed before the commit hook was installed.
Amending the commit to add a gerrit change id.
remote: Processing changes: refs: 1, done
To ssh://<username>@<ip>:29418/test
! [remote rejected] HEAD -> refs/publish/master (no common ancestry)
error: failed to push some refs to 'ssh://<username>@<ip>:29418/test'*
我在以下步骤后得到此错误;
在这里,在最后一步中,如果我使用此命令git push ssh://[username]@[ip]:29418/project_name
,它可以工作。但在这种情况下使用gerrit存储库是没有意义的,因为我直接将它们推送到git而不进行任何审查。此外,我假设当我将这个项目克隆到另一台计算机并将我的更改发送到gerrit存储库时,我将不得不处理这个错误,所以如果我在上面知道我做错了什么会更好。
提前致谢
答案 0 :(得分:1)
不是在新目录中执行git init并添加代码,我建议您克隆新的空的gerrit存储库并在那里进行更改。所以要修改你的步骤:
答案 1 :(得分:0)
HEAD -> refs/publish/master (no common ancestry)
的原因可能是因为master (local)
尚未挂钩master (remote, usually: origion/master)
。为确保这一点,您可以运行git config --list
并查找:
branch.master.remote=origin
branch.master.merge=refs/heads/master
如果缺少这一点,您可以手动直接设置(最好不要):
git config --local branch.master.remote=origin
git config --local branch.master.merge=refs/heads/master
或更好地使用:
git branch --set-upstream-to=origin/master master
分支名称来自:
git branch --all
我的是:
$ git branch --all
* master
remotes/gerrit/master
remotes/origin/master