显示 git 个带有上次提交日期的分支
show git branches with date of last commit
几周前我在一个分支机构工作,但我不记得这个分支机构叫什么(有很多)。我希望能够做类似的事情:
git branch --print-last-commit
并输出如下内容:
branch 1 - 2017-02-12
branch 2 - 2016-12-30
等等
有什么办法吗?
这将打印 BranchName - CommitMessage - 日期为 (YYYY-MM-DD)。您可以 manipulate/edit 此命令行以满足您的需要。
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 提示中。
您可以使用以下命令获取每个分支的所有最后提交
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \t$branch; done | sort -r
我知道这个 post 是旧的,虽然在其他答案的帮助下,我想出了另一个不涉及 bash for 循环的解决方案。
$ paste <(git branch | xargs -I {} git --no-pager show -q --format="%ci %cr" {} | tail -n +1) \
<(git branch) | sort -h | tail -5
2021-10-12 11:24:21 -0700 2 weeks ago adamryman/foobar
2021-10-12 15:20:18 -0700 2 weeks ago adamryman/foobarbaz
2021-10-26 16:46:25 -0700 3 days ago adamryman/baz
2021-10-27 19:00:14 -0700 2 days ago adamryman/foobaz
2021-10-28 14:03:48 -0700 21 hours ago adamryman/barfoo
几周前我在一个分支机构工作,但我不记得这个分支机构叫什么(有很多)。我希望能够做类似的事情:
git branch --print-last-commit
并输出如下内容:
branch 1 - 2017-02-12
branch 2 - 2016-12-30
等等
有什么办法吗?
这将打印 BranchName - CommitMessage - 日期为 (YYYY-MM-DD)。您可以 manipulate/edit 此命令行以满足您的需要。
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 提示中。
您可以使用以下命令获取每个分支的所有最后提交
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \t$branch; done | sort -r
我知道这个 post 是旧的,虽然在其他答案的帮助下,我想出了另一个不涉及 bash for 循环的解决方案。
$ paste <(git branch | xargs -I {} git --no-pager show -q --format="%ci %cr" {} | tail -n +1) \
<(git branch) | sort -h | tail -5
2021-10-12 11:24:21 -0700 2 weeks ago adamryman/foobar
2021-10-12 15:20:18 -0700 2 weeks ago adamryman/foobarbaz
2021-10-26 16:46:25 -0700 3 days ago adamryman/baz
2021-10-27 19:00:14 -0700 2 days ago adamryman/foobaz
2021-10-28 14:03:48 -0700 21 hours ago adamryman/barfoo