Skip to content

Instantly share code, notes, and snippets.

@arturvt
Last active April 16, 2020 07:25
Show Gist options
  • Save arturvt/68ea7c6ba4d5ae72e3364659cbcf5ca2 to your computer and use it in GitHub Desktop.
Save arturvt/68ea7c6ba4d5ae72e3364659cbcf5ca2 to your computer and use it in GitHub Desktop.
Useful git commands

Delete branches

Delete a merged branch

git branch -d branchname

Delete a non merged branch

git branch -D branchname

Remove no longer existing references git-fetch

Before fetching, remove any remote-tracking references that no longer exists. git

git fetch origin --prune

Merged branches

make sure your local is updated with origin: git fetch origin

List merged branches stackoverflow

git branch --merged

List merged branches except the important ones

In this scenario, develop and master are important

git branch --merged| egrep -v "(^\*|master|develop)"

Delete Merged branches

Remove merged except the ones important

In this scenario, develop and master are important

git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d

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