git 远程合并提交导致 gerrit 中出现错误依赖关系
我正在 git 中使用远程分支。在做任何工作之前,我会执行 git pull 来获取 ToT。当我查看 git 日志时,我发现这会自动创建一个合并提交,并显示一条消息:“合并 ssh://myserver:1111/mybranch 的分支‘master’”。然后,我做我的工作并提交我的改变。之后我就把零钱推了上去。我们的系统设置了 gerrit 来进行代码审查。我的新更改显示在 gerrit 中,并依赖于合并提交。我该如何摆脱这个?
I am working with a remote branch in git. Before doing any work, I do a git pull to get the ToT. When I look at the git log, I see that this automatically creates a merge commit with a message: "Merge branch 'master' of ssh://myserver:1111/mybranch". Then, I do my work and commit my change. After that I push my change up. Our system is setup with gerrit for code review. My new change shows up in gerrit with dependency on the merge commit. How do I get rid of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
合并可能没有快进,因为您的分支在拉取之前与远程分支存在差异。那么,当您推动更改时,它可能会在 gerrit 中创建不止一个修订版本,对吗?
使用 gerrit 的最佳方法是在提交和推送任何新更改之前对远程分支进行干净的签出,在这种情况下,您的更改将不会有任何依赖项。我通常会为每个新功能或修复签出一个新分支,我需要推送并保留它们,直到它们被验证并合并到 gerrit 中的主存储库(以防万一需要因修订而更改某些内容并创建新的补丁集)进行相同的更改)。
但是,如果您同时推送多个提交,并且最后一次提交需要前一个提交,那么依赖关系会很有用,例如,如果您向 clean 分支添加了两个提交并推送了它们,则它们将在 gerrit 中显示为两个更改,并且之间具有依赖关系最新的和上一个,最新的将永远不会在依赖之前合并到主存储库。
It is likely that the merge has not been fast-forward because your branch had differences with remote one before pulling. So, when you pushed your change, it has probably created more than one chnage for revision in gerrit, right?
The best approach in the work with gerrit is to do a clean checkout of remote branch before commiting and pushing any new change, in which case your change will not have any dependencies. I usually checkout a new branch for each new feature or fix I need to push and keep them until they were verified and merged to master repo in gerrit (just in case it will be needed to change something as result of revision and create a new patchset for the same change).
However, dependencies are useful if you push more than one commit at the same time and the last commit requres the previous one, say if you added two commits to the clean branch anf pushed them, they will appear in gerrit as two changes with dependency between the latest and the previous, and the latest will commit never be merged to master repositary before the dependant.
如果本地分支是远程跟踪的话,
git pull
实际上是git fetch
和git merge
。因此,如果远程分支不可快速转发,那么 git pull 将创建合并提交。为了避免合并提交,请使用或者
git pull
is actuallygit fetch
andgit merge
if the local branch is remote tracking. So if the remote branch is not fast-forwardable then git pull will create a merge commit. To avoid merge commits useOr