每次我使用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
然后尝试重新定位当前的 master 并向其推送新的更改:
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
造成这种行为的原因(将上游设置为gerrit/master
而不是master
)。
为什么这个分支如此落后?
我可以以某种方式更新它吗?
否则,我能完全摆脱它吗?