[cheat-sheet] Git

remove branches

remove specific branches

$ git branch -D ${some-branch-name-1} ${some-branch-name-2} ...

e.g
$ git branch -D feature/a feature/a

remove all except current

$ git branch -D $(git branch)

remove by pattern

$ git branch -d `git branch --list 'feature/2022-06-*'`

remove all except master & develop branch

$ git branch | grep -v "master" | grep -v "develop" | xargs git branch -D

save username & password

$ git config --global credential.helper store

Last updated

Was this helpful?