Skip to content

Git Shortcuts

5 categories ยท 34 shortcuts

01

Basic

7 shortcuts
  • Initialize a repogitinit
  • Clone a repogitclone<url>
  • Show working tree statusgitstatus
  • Stage a filegitadd<file>
  • Commit staged changesgitcommit-m'msg'
  • Show commit historygitlog
  • Show unstaged changesgitdiff
02

Branching

7 shortcuts
  • List branchesgitbranch
  • Create branchgitbranch<name>
  • Switch branchgitcheckout<branch>
  • Create & switch branchgitcheckout-b<name>
  • Switch branch (newer)gitswitch<branch>
  • Merge branch into currentgitmerge<branch>
  • Delete branchgitbranch-d<name>
03

Staging

7 shortcuts
  • Stage all changesgitadd.
  • Stage hunks interactivelygitadd-p
  • Unstage a filegitreset<file>
  • Unstage everythinggitreset
  • Unstage (newer)gitrestore--staged<f>
  • Stash changesgitstash
  • Apply last stashgitstashpop
04

Remote

6 shortcuts
  • List remotesgitremote-v
  • Add remotegitremoteadd<n><url>
  • Fetch from remotegitfetch
  • Fetch & mergegitpull
  • Push commitsgitpush
  • Push & set upstreamgitpush-uorigin<b>
05

Advanced

7 shortcuts
  • Rebase onto branchgitrebase<branch>
  • Interactive rebasegitrebase-iHEAD~3
  • Discard all changesgitreset--hardHEAD
  • Revert a commitgitrevert<commit>
  • Apply a commit elsewheregitcherry-pick<c>
  • Show reference loggitreflog
  • Create taggittag<name>