标签:iat 查看 called branch 系统 后缀 通过 hooks 补充
背景:并行版本较多,合并至版本发布分支主分支时无法看出初始提交分支
需求:系统开发人员执行git commit时,自动在commit-msg中补充当前所在分支名
操作步骤:
1、在子系统git仓库路径/.git/hooks下,将以下内容覆盖commit-msg.sample文件中
#!/bin/sh # # An example hook script to check the commit log message. # Called by "git commit" with one argument, the name of the file # that has the commit message. The hook should exit with non-zero # status after issuing an appropriate message if it wants to stop the # commit. The hook is allowed to edit the commit message file. # # To enable this hook, rename this file to "commit-msg". branch_name=`git symbolic-ref --short -q HEAD` echo "${branch_name}" commit="<"${branch_name}">"$(cat $1) echo "$commit" > "$1"
2、去掉文件名后缀.sample使其生效
在git-bash中执行commit操作后,通过git log查看提交记录,此时提交信息已成功生效,显示内容为:<分支名>提交信息
标签:iat 查看 called branch 系统 后缀 通过 hooks 补充
原文地址:https://www.cnblogs.com/fantastic-clouds/p/13530680.html