Skip to content

Instantly share code, notes, and snippets.

@zalito12
Created November 2, 2020 10:55
Show Gist options
  • Save zalito12/aaa811b224c0d51e32df1eb09d1033ee to your computer and use it in GitHub Desktop.
Save zalito12/aaa811b224c0d51e32df1eb09d1033ee to your computer and use it in GitHub Desktop.
This is just a note to remind my favorite git aliases when I change my environment
[alias]
co = checkout
push-origin = !git push -u origin \"$(git rev-parse --abbrev-ref HEAD)\"
@zalito12
Copy link
Author

zalito12 commented Nov 30, 2021

Delete all local branches that don't exist on origin

git remote prune origin --dry-run
git branch -vv | grep origin | grep gone | awk '{print $1}'|xargs -L 1 git branch -d
git fetch -p && for branch in `git branch -vv --no-color | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
git co --theirs .

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