Monday, October 8, 2012

Git Cookbook

This page lists some useful commands that I use with Git:
  • Show all branches that contain a commit. Useful to see which branches a topic branch has been merged into.
    • git branch --all --contains commit
  • Show which branches have not been merged into the current or specified branch.
    • git branch --all --no-merge [branch]
  • Pretty-print history tree
    • git log --oneline --graph --decorate --all
  • List all changes that will be sent with the next push
    • git log --branches --not --remotes
  • Update from remote
    • git fetch
    • git rebase -p
  • Get name of remote tracking branch for the current branch
    • git branch -vv | ? { $_ -match '^\*' } | % { $_ -match '\[([^:]+)' | Out-Null; $Matches[1] }
  • Get the most recently modified topic branch
    •  git for-each-ref --sort=-committerdate --format='%(refname)' refs/remotes/origin/topic | select -first 1

0 comments:

Post a Comment