Search all branches created by a user in a GitHub repository

Deadly 提交于 2019-12-12 10:38:53

问题


There was a branch created by a user (knownUserName) in our code repository (repoEx). Where he committed and pushed a few of his changes, but he didn't create a pull request for the same.

It has been long and there is an exponential increase in the number of branches that the repository now has because of which we are unable to go through all the branches and find the one created by him.

Is there a way to search all the branches using the git command line or GitHub interface, to find all the branches created by a user in a specific repository?

I tried using the GitHub interface and filtering the branches (under https://github.com/repoEx/branches/all) using the search parameter as -

author:<knownUserName>

but this won't work. The search seems to be effective with a branch name, but I don't have any clue about the name.


回答1:


Loop on the branch, display the last commit information, and grep on the username.

You will have the commit id you are looking for:

for co in `git branch -a --no-merge`; do  git log -1 --no-walk --pretty=format:"%h - %an, %ar : %s" $co; done | grep <knownUserName>



回答2:


This is for OS X. Just adding grep on to this answer here and modifying for email, you get

git for-each-ref --format='%(committerdate) %09 %(authoremail) %09 %(refname)' | sort -k5n -k2M -k3n -k4n | grep <author-email>

which works quite well.

[Other answer did not work for me, not sure why]



来源:https://stackoverflow.com/questions/41115327/search-all-branches-created-by-a-user-in-a-github-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!