Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
提交时是否可以更改Git标准消息?_Git_Githooks_Git Commit - Fatal编程技术网

提交时是否可以更改Git标准消息?

提交时是否可以更改Git标准消息?,git,githooks,git-commit,Git,Githooks,Git Commit,是否可以更改零件: # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: 说: # Staged: 简单地说,就是那一部分,不 但是您可以使用commit-msg钩子来修改commit-m

是否可以更改零件:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
说:

# Staged:

简单地说,就是那一部分,不


但是您可以使用commit-msg钩子来修改commit-msg。

以一种简单的方式,仅此部分,不需要

但是您可以使用commit-msg钩子来修改commit-msg。

是的,使用prepare-commit-msg钩子。这是.git/hooks/中的一个脚本,它在git生成提交消息和在编辑器中打开提交消息之间运行

作为一个简单的示例,将下面的文本复制到一个名为prepare commit msg in.git/hooks/的新文件中

如果您发现它不能立即工作,请检查它的可执行文件:运行chmod+x.git/hooks/prepare-commit-msg

该脚本是一个sed单行程序,它使用一个prepare-commit-msg钩子将每一行(包括要提交的更改)替换为Staged文本:

Yes。这是.git/hooks/中的一个脚本,它在git生成提交消息和在编辑器中打开提交消息之间运行

作为一个简单的示例,将下面的文本复制到一个名为prepare commit msg in.git/hooks/的新文件中

如果您发现它不能立即工作,请检查它的可执行文件:运行chmod+x.git/hooks/prepare-commit-msg


该脚本是一个sed单行程序,用于将每行(包括要提交的更改)替换为暂存文本:

可能重复:为什么要执行此操作?可能重复:为什么要执行此操作?
#!/bin/sh
sed -i '0,/# Changes to be committed:/c# Staged:' "$1"