首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >当我使用"git branch“的时候,可以显示最新的提交吗?

当我使用"git branch“的时候,可以显示最新的提交吗?
EN

Stack Overflow用户
提问于 2012-07-17 21:58:23
回答 3查看 2.5K关注 0票数 6

因此,在每个分支上,如果我执行"git log“或"git lg",它将显示已完成的提交列表。

现在,当我输入"git branch -arg“时,有没有办法显示每个分支的最新提交?我发现必须检查每个分支,然后使用"git log“检查提交,这有点烦人/乏味。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-17 22:11:43

git branch -v列出了分支名称以及每个分支上最新提交的SHA和commit消息。

请参阅git branch manual page

票数 11
EN

Stack Overflow用户

发布于 2012-07-17 22:05:54

可以,您可以添加结帐后挂钩(described here)。

基本上,创建.git/hooks/post-checkout文件并放入您想要在其中运行的任何git命令,最后确保该文件是可执行的(类unix系统上的chmod +x .git/hooks/post-checkout,例如Mac、GNU/Linux等)。

例如,如果您将git show放入该文件中,它将自动显示最后一次提交,以及在您切换分支时所做的更改。

票数 4
EN

Stack Overflow用户

发布于 2012-07-17 22:33:56

有多个git log参数可以控制其输出:

--branches--glob--tag--remotes选择要显示哪些提交,--no-walk避免显示它们的所有历史记录(只显示它们的提示),--oneline只显示提交日志的第一行,--decorate--color=always添加了更多漂亮的东西:D

尝试以下命令:

代码语言:javascript
代码运行次数:0
运行
复制
$ # 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

顺便说一句,不需要切换分支来查看其他分支的提交:

代码语言:javascript
代码运行次数:0
运行
复制
$ # 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
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11524088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档