Skip to content

This is my Git cheat sheet. There are many like it, but this one is mine.

Here is a short and simple list of some of the common git commands that I find myself using.  This list will be continuously updated as needed.

  • Pull all remote branches
    • git fetch origin
  • To see the branches available for checkout
    • git branch -v -a
  • Create a branch from existing remote
    • git checkout -b NewBranchName origin/OldBranchName
  • Create a branch from existing
    • git checkout -b NewBranchName OldBranchName
  • Push local branch to new remote branch with upstream tracking
    • git push -u origin NewBranchName
  • Push local branch to remote branch with upstream tracking and a new remote branch name
    • git push -u origin local-name:remote-name
  • Show uncommitted changes
    • git status
  • Show Local and Remote branches
    • remote and local
      • git branch -a
    • remote only
      • git branch -r
    • local only
      • git branch
  • Save all local branch changes
    • git add *
  • Commit all saved changes with a message
    • git commit -a -m “message”
  • Pull from remote branch to local branch
    • git pull origin BranchToPull
  • Remove uncommitted local changes
    • reset
      • git reset –hard
    • move back 1
      • git reset –hard HEAD^
    • move back N
      • git reset –hard HEAD~N

 

Written for ServerlessArchitecture.com
Written by Jeff Mangan

Leave a Reply