Skip to content

Instantly share code, notes, and snippets.

@NBprojekt
Last active December 14, 2022 06:24
Show Gist options
  • Save NBprojekt/9f2366717be9a39ed6cecebadc50cd41 to your computer and use it in GitHub Desktop.
Save NBprojekt/9f2366717be9a39ed6cecebadc50cd41 to your computer and use it in GitHub Desktop.

Collection of useful git commands

Show current branch

git branch --show-current

Empty commit to init branch

git commit --allow-empty -m "Init branch"

Delete branch

# Local
git branch -d branch_name
# Remote
git push origin --delete branch_name

Delete all local branches except a given group

# Deletes all branches except "master", "main"
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop\|production" | xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment