Git:在准备真正的合并提交之后,如何创建一个简单的提交? [英] Git: after preparing a real merge commit, how to create a simple commit?

查看:128
本文介绍了Git:在准备真正的合并提交之后,如何创建一个简单的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用 git merge --no-commit< commit> 之后,执行一次提交将导致一个合并提交更多)父母。而不必用 - squash 选项重新执行合并命令)来调用 创建简单提交 p>

解决方案

根据 git-merge man page ,--squash选项不记录 $ GIT_DIR / MERGE_HEAD 。 $ GIT_DIR / MERGE_HEAD 负责创建合并提交;你可以在Git源文件中看到这个文件 builtin / commit.c


in_merge = file_exists(git_path(MERGE_HEAD));

...

if(in_merge){

... //执行merge_commit





解决方案:执行正常合并后, <$> $ GIT_DIR / MERGE_HEAD 以避免获得合并提交。您也可以手动清理 $ GIT_DIR / MERGE_MSG 和$ GIT_DIR / MERGE_MODE,或者在成功提交时将此任务保留为Git。

After invoking git merge --no-commit <commit>, performing a commit will result in a merge commit with two (or more) parents. What command to invoke to create a simple commit instead (without having to re-perform the merge command with the --squash option)?

解决方案

According to the git-merge man page, the --squash option does not record $GIT_DIR/MERGE_HEAD. $GIT_DIR/MERGE_HEAD is responsible for creating merge commits; you can see this in the Git sources, file builtin/commit.c:

in_merge = file_exists(git_path("MERGE_HEAD"));
...
if (in_merge) {
... // Perform merge_commit
}

Solution: after having performed a normal merge, simply get rid of $GIT_DIR/MERGE_HEAD to avoid getting a merge commit. You may manually clean up $GIT_DIR/MERGE_MSG and $GIT_DIR/MERGE_MODE as well or leave this task up to Git upon successful commit.

这篇关于Git:在准备真正的合并提交之后,如何创建一个简单的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆