Last active
November 26, 2023 23:24
-
-
Save fabioperrella/1f56229a4c532fc000ed to your computer and use it in GitHub Desktop.
Bash script to clean git merged branches (local and remote). Thanks to Eron Junior to introduce me the command "git fetch -p"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -xe | |
git checkout master | |
git fetch | |
git pull | |
git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete || true | |
git branch --merged | grep -v master | xargs git branch -d || true | |
git fetch -p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment