因此,在每个分支上,如果我执行"git log“或"git lg",它将显示已完成的提交列表。
现在,当我输入"git branch -arg“时,有没有办法显示每个分支的最新提交?我发现必须检查每个分支,然后使用"git log“检查提交,这有点烦人/乏味。
发布于 2012-07-17 14:11:43
git branch -v
列出了分支名称以及每个分支上最新提交的SHA和commit消息。
发布于 2012-07-17 14:05:54
可以,您可以添加结帐后挂钩(described here)。
基本上,创建.git/hooks/post-checkout
文件并放入您想要在其中运行的任何git命令,最后确保该文件是可执行的(类unix系统上的chmod +x .git/hooks/post-checkout
,例如Mac、GNU/Linux等)。
例如,如果您将git show
放入该文件中,它将自动显示最后一次提交,以及在您切换分支时所做的更改。
发布于 2012-07-17 14:33:56
有多个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
顺便说一句,不需要切换分支来查看其他分支的提交:
$ # 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
https://stackoverflow.com/questions/11524088
复制