Changing format for git branch -vv

2020-07-23 06:32发布

问题:

I like the -vv format for "git branch -vv" but would like to add "%(committerdate:relative)" to the format and --sort=-committerdate

I've struggled to find the right format from the code (https://github.com/git/git/blob/ccdcbd54c4475c2238b310f7113ab3075b5abc9c/ref-filter.c) but haven't been able to figure it out.

Two questions: - Does anyone have an alias in their .gitconfig for this? - Where in the git/git code is -vv implemented? (https://github.com/git/git)

Thanks

回答1:

Look at the formatting options of git for-each-ref

A starting point for the format could be :

--format='%(refname:short) %(upstream) %(committerdate) %(contents:subject)'

You would list references under refs/heads :

git for-each-ref refs/heads --format=...

git for-each-ref understands --sort too



标签: git