2017-06-12 89 views
2

几周前我正在分支,但我不记得分支被称为什么(有很多)。我希望能够做这样的事情:显示git分支与上次提交日期

git branch --print-last-commit

,并为它的输出是这样的:

branch 1 - 2017-02-12 
branch 2 - 2016-12-30 

有没有办法做到这一点?

回答

4

这将打印BranchName - CommitMessage - 日期为(2017-06-09)。你可以操纵/编辑这个命令行来适应你的需要。

git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:short)%(color:reset))' 

请注意,它将打印所有本地分支,而不仅仅是当前分支。您可以为了方便创建别名。

[alias] 
     branchcommits = !git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:short)%(color:reset))' 

并运行GIT中branchcommits在GIT中bash提示符。

enter image description here

+0

谢谢:-)这太棒了! –