自动添加分支名称以在Github中提交(桌面)

问题描述 投票:-1回答:1

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

目前,每次提交内容时,我都必须手动将其写下来:

[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 Desktop。

git github github-for-windows github-desktop
1个回答
0
投票

如果出于某种原因您不想在此处使用钩子,那么简单的别名就可以解决问题:

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
© www.soinside.com 2019 - 2024. All rights reserved.