3 ms·
Here's my favorite git oneliner: git push origin --delete $(git branch --merged origin/master -r | grep -v master | grep origin | cut -d/ -f2-) It deletes a
by majewsky 11y ago
Here's my favorite git oneliner:
git push origin --delete $(git branch --merged origin/master -r | grep -v master | grep origin | cut -d/ -f2-)
It deletes all remote branches that are merged into the remote master. Because people always forget to click the "Delete branch" button after merging their pull requests.
EDIT: And another thing. Turn all your Git aliases into shell aliases (e.g. "git status" is aliased to "git st" is aliased to just "st" on my system) with this one weird trick! https://github.com/majewsky/devenv/blob/2c4252d37597617a493f1addadacfbf8d88b4942/toplevel/zshrc#L55-L59 https://github.com/majewsky/devenv/blob/2c4252d37597617a493f...
- pavel_lishin 11y agoIs there a dry-run option for this?
- ataylor32 11y agoJust run everything that's inside $(), which is this: git branch --merged origin/master -r | grep -v master | grep origin | cut -d/ -f2-
- brbsix 11y agoWhile not an issue in Zsh, one bummer about using shell aliases in Bash is that auto-completion won't work. That doesn't really matter with an alias for `git status`, but it's annoying for plenty of others. You can get around it doing the following: _completion_loader git # manually load git completion functions alias g='git' __git_complete g _git alias ga='git add' __git_complete ga _git_add For a more exhaustive list, see https://gist.github.com/brbsix/713feaf3034d60bbe4774cb8ee03bd55#file-bash_aliases https://gist.github.com/brbsix/713feaf3034d60bbe4774cb8ee03b....
- Tharkun 11y agoWhy would you want to delete merged branches? i like to keep them. It's not costing you any storage.
- daviross 11y agoBeautiful, I've been looking for something like this for a while. My only issue is getting a strange fatal: remote part of refspec is not a valid name in :MARKET-446 error which seems resistant to the usual sort of tweaks.
- therealdrag0 11y agoI'm getting errors such as: `error: unable to delete 'feature/cleanup-casts': remote ref does not exist`. But the branch does exist... Any ideas?
- therealdrag0 11y agoFixed by fetching to prune first.