Skip to content

Commit

Permalink
Add option for deleting local merged branches
Browse files Browse the repository at this point in the history
  • Loading branch information
draperunner committed May 6, 2019
1 parent 3c03698 commit 843ecd6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions git-pretty.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function main() {
console.log("1: An uncommitted mess")
console.log("2: I accidentally committed something")
console.log("3: My Git history is ugly")
console.log("4: I have a bunch of old branches I want gone")
let response = prompt("> ")
console.log()

Expand Down Expand Up @@ -211,6 +212,16 @@ function main() {
}
}
}

if (response == "4") {
console.log("To delete all local branches that are already merged into the currently checked out branch:")
console.log()
console.log('git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d')
console.log()
console.log("You can see that master and dev are excluded in case they are an ancestor.")
console.log("Check out https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged")
return "4"
}
}

main()

0 comments on commit 843ecd6

Please sign in to comment.