I've been contributing to a project for many years. I've made hundreds of PRs on github via the browser. I've noticed now that I have many many patch branches and would like to clean these up. I've tried with git bash, but I'm failing to understand it. Example: This PR was merged and I have the option at the bottom to "Delete branch". How can I do that with all merged patches?
I've been contributing to a project for many years. I've made hundreds of PRs on github via the browser. I've noticed now that I have many many patch branches and would like to clean these up. I've tried with git bash, but I'm failing to understand it. Example: https://github/citation-style-language/styles/pull/7476 This PR was merged and I have the option at the bottom to "Delete branch". How can I do that with all merged patches?
Share Improve this question asked Mar 18 at 9:45 POBrien333POBrien333 234 bronze badges1 Answer
Reset to default 2If you only use the GitHub website: Go to your fork, then click on "XX branches" above the file list. Then select the "Active" tab and start deleting your branches one by one from there.
If you have a local Git clone of the repository: Use git push
to delete a branch from the remote repository.
For example:
git push --delete myfork patch-743604 patch-12345 patch-23456
To mass-delete all patch-*
branches (first with -vn
for a "dry run" to verify that it's going to do the correct thing, then without -vn
to actually do it):
git ls-remote origin | awk '{print $2}' | grep ^refs/heads/patch- | xargs git push -vn --delete myfork
Alternative syntax (using local:remote
to push "nothing"):
git push myfork :patch-743604 :patch-12345 :patch-23456