我如何配置git commit为git commit -v默认情况下充当(显示正在提交的完整差异)?
使用别名并不十分令人满意,因为它不会影响可能间接提交的操作期间的提交消息编辑,例如git rebase.
小智 54
如果您使用的是git 2.9,可以使用配置来完成.
git config --global commit.verbose true
Run Code Online (Sandbox Code Playgroud)
Git 2.9.0发行说明:https: //github.com/git/git/blob/v2.9.0/Documentation/RelNotes/2.9.0.txt
"git commit"学会了注意"commit.verbose"配置变量,并且好像从命令行给出了"--verbose"选项.
asm*_*rer 30
据我所知,你不能用别名覆盖已经存在的git命令(否则,将无法执行原始命令,并且会破坏一堆东西).
所以我建议你做点什么git config --global "alias.ci" "commit -v".这将行添加到您的~/.gitconfig文件,并让这个git ci做git commit -v.然后你应该养成打字的习惯git ci而不是git commit(除非你决定不想要-v).
小智 9
好吧,我使用别名:
alias gc='git commit -v'
Run Code Online (Sandbox Code Playgroud)
我相信,有很多很好的别名,我从PeepCode git截屏视频中脱颖而出.
小智 6
我知道这是一个古老的问题,但我碰巧碰到了它,并得到了答案.我在.bash_profile中添加了以下函数:
#!/bin/bash
git()
{
case "$1" in
ci|commit)
gitargs=""
for i in $@; do
if [ "$1" != "$i" ]; then
gitargs="$gitargs $i"
fi
done
command git commit -v $gitargs
;;
*)
command git "$@"
;;
esac
}
Run Code Online (Sandbox Code Playgroud)
这变成git了一个bash函数,它可以转换git commit为git commit -v其余的参数并且只留下其余的参数.但是,它会破坏git commit具有空格的参数,并且不允许您提交名为cior 的文件commit.