Co-Authored-By 可以在你和小伙伴pair时,把他的头像也加入到commit log中, 做法就是在commit message末尾加入这一行
Co-authored-by: name <name@example.com>
这个小工具可以帮你快速的生成这个 commit footer. 并且提供了方便管理这个脚本的方法.
初次使用时, 在 alias 一栏填入小伙伴名称的缩写,如 "mt", 在username和email中填入对方git仓库的用户名和邮箱, 然后点击添加.
添加好小伙伴后, 点击右侧的copy, 然后粘贴在命令行中. OK, 所有的准备工作都做好啦.
接下来在你需要commit时, 使用 git cc --co mt -m "your commit message", 然后提交代码,
就可以在仓库中看到你和小伙伴的头像一起出现在同一个commit中啦!
如果需要修改小伙伴们, 先在命令行中执行 git config --global alias.cc, 将打印出的内容复制下来, 然后粘贴在下方文本区中, 点击“导入”, 就可以看到小伙伴们被解析出来啦.
你可以直接在表格中修改小伙伴的信息, 借助Vue的方便, 最终的脚本会实时的被更新在右侧, 修改完毕后点击右侧的copy按钮, 粘贴回命令行即可.
或者导入来自 git config --global alias.cc 已有的片段
| Alias | Username | |||
|---|---|---|---|---|
| {{index+1}} |
使用方法:点击下面的按钮复制代码,粘贴在命令行中
每次提交代码时用 git cc 代替 git commit git cc --co <alias> -m <message>,
!co_authored_commit_by() {
usage="usage: git cc --co <user-alias> [-m <commit-message>] ...";
rest="";
message="";
while [ "${#}" -gt 0 ]; do
case "${1}" in
-m|--message)
shift;
message="${1}";
shift;;
--co)
shift;
co_username="${1}";
case $co_username in
"{{author.alias}}") co_author_msg="{{author.username}} <{{author.email}}>" ;;
*) echo "No such user, you can select them:\n{{authors.map(item => `${item.alias}(${item.username})`).join('\\n')}}"; exit 1;;
esac;
co_author="Co-authored-by: ${co_author_msg}\n";
shift;;
*)
rest="$rest ${1}";
shift;;
esac;
done;
if [ -z "${co_author}" ]; then
echo "${usage}";
exit 1;
fi;
co_authored_message="${message}\n\n${co_author}";
echo "==== 🎉: Great you did pair today, 🐸 +1s ====\n";
git commit -m "${co_authored_message}" $rest;
};
co_authored_commit_by