简体   繁体   English

git merge-不提交编辑

[英]git merge --no-commit with edits

If I use 如果我用

git merge --no-commit <other-branch>

and then make changes, such as removing files from the merge, is this still a real merge? 然后进行更改,例如从合并中删除文件,这仍然是真正的合并吗?

I would like the branches to be related (with a merge), but I don't want all of the changes in the in the new branch. 我希望将分支关联(合并),但是我不希望新分支中的所有更改。

As a more concrete example, other-branch is a release branch from an older version. 作为更具体的示例,other-branch是较旧版本的发行分支。 The current branch is the develop branch of the current product. 当前分支是当前产品的开发分支。 We've made some changes for the release branch that should be moved to the develop branch. 我们对发布分支进行了一些更改,这些更改应移至开发分支。

We've used cherry-picks in the past, but I feel like there may be an advantage to having git understand a relationship between the two branches. 过去我们使用过樱桃小贴士,但是我觉得让git理解两个分支之间的关系可能会有好处。

Is an edited merge still a merge? 编辑的合并仍是合并吗?

Yes, it is still a merge. 是的,它仍然是合并。 It doesn't matter whether you run git merge <other-branch> , or git merge --no-commit <other-branch> , the result will be a merge commit, that has two parents. 无论运行git merge <other-branch>还是git merge --no-commit <other-branch> ,结果将是具有两个父级的合并提交。 The --no-commit option simply stops and lets you investigate that the merge went well before you commit the merge. --no-commit选项只是停止并允许您在提交合并之前调查合并是否顺利。

The --no-commit option simply stops and lets you investigate that the merge went well before you commit the merge. --no-commit选项只是停止并允许您在提交合并之前调查合并是否顺利。

This is now documented in Git 2.22 (Q2 2019) 现在已在Git 2.22(2019年第二季度)中进行了记录

See commit 1ede45e (21 Feb 2019) by Elijah Newren ( newren ) . 参见Elijah Newren( newren )的 commit 1ede45e (2019年2月21日
(Merged by Junio C Hamano -- gitster -- in commit 082c15a , 07 Mar 2019) (由Junio C gitster - gitstercommit 082c15a中合并 ,2019年3月7日)

merge-options.txt : correct wording of --no-commit option merge-options.txt :-- --no-commit选项的正确措词

The former wording implied that --no-commit would always cause the merge operation to "pause" and allow the user to make further changes and/or provide a special commit message for the merge commit. 前一词暗示--no-commit总是会导致合并操作“暂停”,并允许用户进行进一步的更改和/或为合并提交提供特殊的提交消息。

This is not the case for fast-forward merges , as there is no merge commit to create. 快进合并不是这种情况 ,因为没有要创建的合并提交。

Without a merge commit, there is no place where it makes sense to "stop the merge and allow the user to tweak changes"; 没有合并提交,就没有地方“停止合并并允许用户调整更改”; doing that would require a full rebase of some sort. 这样做将需要某种形式的完整基础。

Since users may be unaware of whether their branches have diverged or not, modify the wording to correctly address fast-forward cases as well and suggest using --no-ff with --no-commit if the point is to ensure that the merge stops before completing. 由于用户可能不知道自己的分支是否分开,因此修改措辞以正确处理快进案例,并建议使用--no-ff--no-commit以确保合并停止在完成之前。

The documentation is clearer: 文档更加清晰:

With --no-commit perform the merge and stop just before creating a merge commit, to give the user a chance to inspect and further tweak the merge result before committing. 使用--no-commit可以在创建合并提交之前执行合并和停止操作,从而使用户有机会在提交之前检查并进一步调整合并结果。

Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit . 请注意,快进更新不会创建合并提交,因此无法通过--no-commit停止这些合并。
Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit . 因此,如果要确保合并命令不会更改或更新分支,请使用--no-ff--no-commit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM