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