git 远程合并提交导致 gerrit 中出现错误依赖关系

发布于 2024-12-04 00:34:58 字数 226 浏览 1 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

微暖i 2024-12-11 00:34:58

合并可能没有快进,因为您的分支在拉取之前与远程分支存在差异。那么,当您推动更改时,它可能会在 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.

我们只是彼此的过ke 2024-12-11 00:34:58

如果本地分支是远程跟踪的话,git pull实际上是git fetchgit merge。因此,如果远程分支不可快速转发,那么 git pull 将创建合并提交。为了避免合并提交,请使用

'git fetch'
'git rebase -p'
'git pull --rebase' 

或在 git 配置中将 merge.ff 设置为 only 值。

或者

从本地分支禁用远程跟踪设置 git
config --unset 分支。<分支>.merge

git pull is actually git fetch and git 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 use

'git fetch'
'git rebase -p'
'git pull --rebase' 

or set the merge.ff with value only in the git config.

Or

disable the remote tracking settings from the local branch git
config --unset branch.<branch>.merge

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文