如何自动化git merge以不提示确认提交消息?

buz*_*ord 21 git automation

我正在尝试使用git做一些自动化脚本,简单的事情,如更新子模块,移动到正确的标签等,但我现在发现的一个问题是git现在强制你确认合并消息.有没有办法压制这种行为?

zia*_*aab 35

您可以添加--no-edit开关git-merge,它不会要求您确认合并消息.

  • 较新版本(> = 1.7.10)的git merge default进入交互式会话.您必须添加--no-edit参数或添加环境变量GIT_MERGE_AUTOEDIT = no以禁止交互式会话 (3认同)

ola*_*ola 16

为了防止git在Mac上向你发送提交消息,请将其添加到.bashrc或.bash_profile中(详细了解两个文件之间的区别)

export GIT_MERGE_AUTOEDIT=no
Run Code Online (Sandbox Code Playgroud)

然后在你的终端类型:

source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

重新加载你的bash文件并继续不受任何干扰.


小智 5

使用这个命令:

git merge other_branch --commit --no-edit
Run Code Online (Sandbox Code Playgroud)

--commit 在合并后立即自动提交。

--no-edit 以防止显示提交消息编辑器。