MSNCodeSNIPPETS← msncode.dev
snippets/git

Delete All Merged Branches

Clean up local branches that have been merged into main

gitbashbranchcleanup
BASH
git branch --merged main | grep -v main | xargs git branch -d

More git snippets

Amend Last Commit Message

Change the message of your most recent commit

Cherry-Pick a Commit

Apply a specific commit from another branch

Create and Switch Branch

Create a new branch and switch to it in one command

Force Push Safely

Force push only if no one else has pushed in the meantime