Skip to content

Instantly share code, notes, and snippets.

@dreamorosi
Created October 27, 2020 14:28
Show Gist options
  • Save dreamorosi/1929c4782b1326c7d3b7f134142bd348 to your computer and use it in GitHub Desktop.
Save dreamorosi/1929c4782b1326c7d3b7f134142bd348 to your computer and use it in GitHub Desktop.
Useful Git Commands

Prune local branches that don't exist anymore on remote

git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done

Undo last local commit but keep changes

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