如何自动将当前正在使用的分支名称添加到提交中?
目前,每次提交内容时,我都必须手动将其写下来:
[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 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