简体   繁体   English

防止git在合并后自动提交:--no-commit默认

[英]Prevent git from automatic commit after merge: --no-commit by default

I've switched to Git recently from bzr, and while I've gotten used to the differences there is one thing I am wondering if it is possible: 我最近从bzr切换到Git,虽然我已经习惯了差异,但是有一件事我想知道是否有可能:

In bzr, when you merge there is not a implicit commit. 在bzr中,合并时没有隐式提交。 The reasoning behind this is while the merge might have been technically successful, it might not have been contextually correct ie. 其背后的原因是,虽然合并在技术上可能已经成功,但在上下文上可能并不正确。 not all of the unit tests pass after the merge so I may have to touch things up to make a "correct" merge. 并不是所有的单元测试都在合并后通过,所以我可能需要动手做一个“正确的”合并。

I read the Git doc and thought I could do this with an alias, but it doesn't work: 我阅读了Git文档,并认为可以使用别名来做到这一点,但是它不起作用:

[alias] 
merge = 'merge --no-commit'

While I could just make a separate name for no-commit-merge, I would rather set this as the default behavior. 虽然我可以为no-commit-merge单独命名,但是我宁愿将其设置为默认行为。

Other people suggest I 'rebase' with master, before merging back in. This would create a fast-forward merge, and would give me the chance to test the changes contextually before making it part of mainline but I would prefer to avoid rebase as much as possible. 其他人建议我在重新合并之前先与master进行“重新设置”。这将创建一个快速合并,并让我有机会在将其作为主线的一部分之前进行上下文相关的测试,但我宁愿避免尽可能多地进行重新设置尽可能。

So, is it possible to change the default merge behavior to --no-commit? 因此,是否可以将默认合并行为更改为--no-commit?

You can set the branch.<name>.mergeoptions config appropriately with the no-commit flag so that it does that by default: 您可以使用no-commit标志来适当地设置branch.<name>.mergeoptions配置,以使其在默认情况下能够做到:

branch. 科。 <name> .mergeoptions <name> .mergeoptions

Sets default options for merging into branch <name> . 设置用于合并到分支<name>默认选项。 The syntax and supported options are the same as those of git merge, but option values containing whitespace characters are currently not supported. 语法和支持的选项与git merge相同,但是当前不支持包含空格字符的选项值。

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

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