以下命令列出了我所有本地分支的最后提交哈希和分支名称:
git show-ref --heads
输出:
<hash> <branch-1>
<hash> <branch-2>
...
<hash> <branch-n>
但是,我还想查看每个分支的日期。以下命令仅显示当前分支上最后一次提交的日期和哈希,但不显示分支名称:
git log -1 --format="%ci %H"
输出:
<date> <hash>
我怎样才能得到两者结合的结果?
<date> <hash> <branch-1>
<date> <hash> <branch-2>
...
<date> <hash> <branch-n>
我使用的 Windows 10 没有花哨的命令环境,只有基本的命令提示符。
最佳答案
我能够稍微调整 this great GitHub post 以获得以下内容:
$ for branch in `git branch | grep -v HEAD`;do echo -e
`git show --format="%ci %cr %H" $branch | head -n 1` \\t$branch; done | sort -r
输出:
2017-03-07 11:38:38 +0800 2 hours ago 87ed1306a1c06576043cd398097a1dc0ec456632 branch1
2017-03-07 02:50:06 +0000 3 hours ago 577fe106a9eb5763cbfd5bce87cfa9448ef52ca8 master
2017-03-07 02:50:06 +0000 3 hours ago 577fe106a9eb5763cbfd5bce87cfa9448ef52ca8 branch2
2017-03-03 17:07:05 +0800 4 days ago 419a23b246ad932c9659b70fded4b1362e92d884 branch3
关于windows - 获取所有分支的日期、散列和分支名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42640696/