我想找出是谁创建了分支。

我有能力这样做:

git branch -a | xargs -L 1 bash -c 'echo "$1 `git log --pretty=format:"%H %an" $1^..$1`"' _

但是,这将返回每个分支的最后一个提交者,而不一定是创建该分支的人。


当前回答

我们可以根据作者名找到答案

git for-each-ref --format='%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)' refs/remotes/ --sort=authorname DESC

其他回答

按提交日期排序的作者列出远程Git分支:

git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' --sort=committerdate

据我所知,您可以看到您是否只是一个分支的创建者。这由.git/ref/heads/<branch>中的第一行表示。如果它以“Created from HEAD”结尾,你就是创造者。

我们可以根据作者名找到答案

git for-each-ref --format='%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)' refs/remotes/ --sort=authorname DESC
git for-each-ref --format='%(authorname) %09 -%(refname)' | sort

我通过使用——sort标志调整了前面的答案,并添加了一些颜色/格式:

git for-each-ref --format='%(color:cyan)%(authordate:format:%m/%d/%Y %I:%M %p)    %(align:25,left)%(color:yellow)%(authorname)%(end) %(color:reset)%(refname:strip=3)' --sort=authordate refs/remotes