Skip to content

Instantly share code, notes, and snippets.

@karuppasamy
Created July 25, 2016 04:20
Show Gist options
  • Save karuppasamy/591d484b4211636785ac16d5e19c7f6b to your computer and use it in GitHub Desktop.
Save karuppasamy/591d484b4211636785ac16d5e19c7f6b to your computer and use it in GitHub Desktop.
Git - Delete remote branches
# Delete remote branches except `master` and `development`
git branch -r --merged | grep origin | grep -v '>' | grep -v master | grep -v development | grep -v sprint | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete > ~/Documents/remote_branch
@karuppasamy
Copy link
Author

Workout

git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
cut -d"/" -f2- |
xargs git push -d b

git branch -r --merged | grep origin | grep -v '>' | grep -v master | grep -v development | grep -v sprint > ~/Documents/remote_branch

git branch -r --merged | grep origin | grep -v '>' | grep -v master | grep -v development | grep -v sprint | xargs -L1 | cut -d"/" -f2- > ~/Documents/remote_branch

git branch -r --merged | grep origin | grep -v '>' | grep -v master | grep -v development | grep -v sprint | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete > ~/Documents/remote_branch

git branch -r --merged | grep origin | grep -v '>' | grep -v master | grep -v development | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete > ~/Documents/remote_branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment