Skip to content

Instantly share code, notes, and snippets.

@chrisgalvan
Last active August 29, 2015 14:25
Show Gist options
  • Save chrisgalvan/4badd2627c7eb70ce046 to your computer and use it in GitHub Desktop.
Save chrisgalvan/4badd2627c7eb70ce046 to your computer and use it in GitHub Desktop.
Useful Git commands
// See wich remote branches contain specific commit
git branch -r --contains COMMIT_HASH
// See a log for only commits unique to a branch
git log --no-merges [branch for log] --not [branches to exclude]
//
git log --first-parent --no-merges
// Change push configuration to only do the current branch
git config --global push.default simple
// List branches in desc order starting with the most recent commit
git for-each-ref --sort=-committerdate refs/heads/
// Remove local branches that have been deleted in remote
git checkout master
git fetch -a -p
git branch -vv | where { $_ -notmatch "\[origin\/" } | % { $_ } | sls -pattern "\S*\/\S*" | % { $_.Matches } | % { $_.Value } | select { "git branch -d $_" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment