Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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
自动将分支名称添加到Github(桌面)中的提交_Git_Github_Github For Windows_Github Desktop - Fatal编程技术网

自动将分支名称添加到Github(桌面)中的提交

自动将分支名称添加到Github(桌面)中的提交,git,github,github-for-windows,github-desktop,Git,Github,Github For Windows,Github Desktop,如何将当前正在处理的分支名称自动添加到提交中 目前,每当我提交某项内容时,我都必须手动将其记录下来: [v1.2-branch-name] I did something [v1.2-branch-name] I did something else [v1.2-otherbranch-name] I did something else that did not mess up my code 我目前使用的是Github桌面。如果出于任何原因您不想在此处使用钩子,一个简单的别名就可以做到:

如何将当前正在处理的分支名称自动添加到提交中

目前,每当我提交某项内容时,我都必须手动将其记录下来:

[v1.2-branch-name] I did something
[v1.2-branch-name] I did something else
[v1.2-otherbranch-name] I did something else that did not mess up my code

我目前使用的是Github桌面。

如果出于任何原因您不想在此处使用钩子,一个简单的别名就可以做到:

git config alias.cm '!f() { git commit -m "$(git rev-parse --abbrev-ref HEAD) $1"; }; f'
然后,假设您当前的分支名为
v1.2-branch-name

git cm "My marvelous message"
实际上会创建一个包含以下消息的提交

v1.2-branch-name My marvelous message

这回答了你的问题吗?这很好,但是如果我使用桌面应用程序提交git,它是否也可以工作?