Reputation: 1362
The command git branch -a
produces a list of over 250 branches. I'd like to know which are mine so I can verify they're merged to production and then delete the remotes.
Is there git command to show me all the remote branches I created? This would be easier if all the branches I created were still in my local repo, however I recently got a new computer so my local repo was lost. I don't have the branches locally, nor do I have a complete reflog.
Upvotes: 0
Views: 490
Reputation: 1757
Assuming that the branches that you created are those for which the last commit was performed by you (is it correct for your case?), here is a small python script I wrote which could solve your problem:
#!/usr/bin/python
import subprocess
remotes_output = subprocess.check_output("git branch -r".split())
remotes = remotes_output.split()[2:]
author_cmd = lambda b: "git log -1 --pretty=format:'%%an' %s" % b
for branch_name in remotes:
print '%s : %s' % (branch_name, subprocess.check_output(author_cmd(branch_name).split()))
It takes the names of the remote branches, removes the first entry which is just the mapping for HEAD and prints out their authors - in the sense written above.
Now, copy this script to a file and grep the output in your shell:
python this_script.py | grep 'your name in git'
Upvotes: 2