显示git分支与上次提交的日期

Der*_*ins 4 git version-control git-branch

几周前我在一个分支机构工作,但我不记得分支机构的名称(有很多).我希望能够做到这样的事情:

git branch --print-last-commit

并输出如下内容:

branch 1 - 2017-02-12
branch 2 - 2016-12-30
Run Code Online (Sandbox Code Playgroud)

等等

有没有办法做到这一点?

Sau*_*ahu 8

这将打印BranchName - CommitMessage - Date as(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))'
Run Code Online (Sandbox Code Playgroud)

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

[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))'
Run Code Online (Sandbox Code Playgroud)

并在git bash提示符下运行git branchcommits.

在此输入图像描述