为什么分支gerrit / master远远落后?

时间:2017-03-21 23:38:02

标签: git gerrit git-review

每次我使用git-review结帐到评论分支时,如:

j ❯❯❯ git-review -d 5779
Downloading refs/changes/79/5779/1 from gerrit
Switched to branch "review/jezor/5779"

status命令告诉我,我领先于gerrit/master分支:

j ❯❯❯ git status
On branch review/jezor/5779
Your branch is ahead of 'gerrit/master' by 364 commits.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean

所以我检查了gerrit/master分支:

j ❯❯❯ git checkout gerrit/master
Note: checking out 'gerrit/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at cb563f2e... Old, old commit from six months ago

然后尝试重新定位当前的主人并推送新的更改:

j ❯❯❯ git pull --rebase origin master
From ssh://my.projects.review:29418/some_project
 * branch              master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Fast-forwarded HEAD to dcf5ac6807455dcca33e288d830515c6bfe89aa0.

j ❯❯❯ git push origin HEAD:gerrit/master
error: unable to push to unqualified destination: gerrit/master
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to 'ssh://jezor@my.projects.review:29418/some_project'

......正如你所看到的那样,没有成功。

它并不会让我或我的团队感到烦恼,因为我们已经习惯了。尽管保持存储库清洁会很好。我猜git-review脚本中this line负责此行为(将上游设置为gerrit/master而不是master)。

为什么这个分支落后了?

我能以某种方式更新吗?

否则,我可以完全摆脱它吗?

1 个答案:

答案 0 :(得分:1)

首先,让我们澄清“master”和“gerrit / master”之间的区别:

  • master =是名为master的本地分支(仅存在于本地存储库中),如果执行“git commit”,“git merge”或“git rebase”等命令,则会更新。

    < / LI>
  • gerrit / master =是一个名为master的远程分支的本地表示(每个克隆存储库的人都可以访问),每次执行“git fetch”命令时都会更新。 “gerrit”术语指向远程存储库。可能git-review会自动创建“gerrit”遥控器,因为当“defaultremote”属性未在“.gitreview”git-review配置文件中明确定义时,这是默认名称。

要检查的事项:

  • .gitreview文件中的定义
  • “git remote -v”命令的结果
  • “git remote show gerrit”和“git remote show origin”命令的结果。