2012-07-17 71 views

回答

3

是的,你可以添加一个后结帐钩(described here)。

基本上,创建.git/hooks/post-checkout文件,并把你想运行的任何git命令放在里面,最后确保这个文件是可执行文件(chmod +x .git/hooks/post-checkout在类似Unix的系统上,比如Mac OS,GNU/Linux等) 。

例如,如果您将git show置于该文件中,它将自动向您显示上次提交以及每次切换分支时所做的更改。

+0

为将来肯定有用。谢谢! – iCodeLikeImDrunk 2012-07-17 14:29:50

1

有多种git log参数来控制其输出:

--branches--glob--tag--remotes选择哪些承诺表明,--no-walk避免显示所有历史记录(只是他们的技巧,只要你想),--oneline仅示出了提交日志的第一行,并--decorate--color=always添加更多的眼睛糖果:d

尝试这些命令:

$ # show the first line of the commit message of all local branches 
$ git log --oneline --decorate --color=always --branches --no-walk 

$ # show the whole commit message of all the branches that start with "feature-" 
$ git log --decorate --color=always --branches='feature-*' --no-walk 

$ # show the last commit of all remote and local branches 
$ git log --decorate --color=always --branches --remotes --no-walk 

$ # show the last commit of each remote branch 
$ git fetch 
$ git log --decorate --color=always --remotes --no-walk 

BTW,没有必要改用树枝看其他分支的提交:

$ # show the 'otherbranch' last commit message 
$ git log --decorate --color=always -n 1 otherbranch 

$ # show a cool graph of the 'otherbranch' history 
$ git log --oneline --decorate --color=always --graph otherbranch 
+0

好吧,我找到了正确的开关来避免遍历分支历史,使用'--no-walk'和'--branches' – KurzedMetal 2012-07-17 14:43:04

相关问题