因此,如果我在每个分支上执行“git log”或“git lg”,它将显示完成的提交列表。当我使用“git分支”时可以显示最新的提交吗?
现在,当我输入“git branch -arg”时,有没有办法显示每个分支上的最新提交?我发现检查每个分支然后使用“git log”检查提交有点烦人/乏味。
因此,如果我在每个分支上执行“git log”或“git lg”,它将显示完成的提交列表。当我使用“git分支”时可以显示最新的提交吗?
现在,当我输入“git branch -arg”时,有没有办法显示每个分支上的最新提交?我发现检查每个分支然后使用“git log”检查提交有点烦人/乏味。
git branch -v
列出分支名称以及每个分支上最新提交的SHA和提交消息。
是的,你可以添加一个后结帐钩(described here)。
基本上,创建.git/hooks/post-checkout
文件,并把你想运行的任何git命令放在里面,最后确保这个文件是可执行文件(chmod +x .git/hooks/post-checkout
在类似Unix的系统上,比如Mac OS,GNU/Linux等) 。
例如,如果您将git show
置于该文件中,它将自动向您显示上次提交以及每次切换分支时所做的更改。
为将来肯定有用。谢谢! – iCodeLikeImDrunk 2012-07-17 14:29:50
有多种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
好吧,我找到了正确的开关来避免遍历分支历史,使用'--no-walk'和'--branches' – KurzedMetal 2012-07-17 14:43:04
踢屁股!谢谢! – iCodeLikeImDrunk 2012-07-17 14:25:46