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

我有能力这样做:

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

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


当前回答

我通过使用——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

其他回答

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

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

DarVar补充道:

git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n | awk '{print $7 $8}'

附注:我们使用AWK来漂亮地打印作者和远程分支。

我知道这不是问题的全部范围,但如果你发现只需要过滤特定作者提交的文件,你总是可以管道到grep:)

# lists all commits in chronological order that
# belong to the github account with
# username `MY_GITHUB_USERNAME` (obviously you
# would want to replace that with your github username,
# or the username you are trying to filter by)


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

编码快乐!:)

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

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