[Guide] Git command line aliases

Users who are viewing this thread

The Git command line can be accessed under Windows Explorer with the "Git Bash" context menu entry, and from Git Extensions with the menu "Git -> Git bash" or Ctrl-G. You can shorten commonly used commands by adding aliases to the main configuration file, probably located at "C:\Users\your user name\.gitconfig". Some of the relevant ones that I use are listed below:

[alias]
  st = status
  co = checkout
  cob = checkout -b
  br = branch -v
  ci = commit
  cim = commit -m
  cia = commit --amend
  cic = commit -c
  di = diff --relative
  dicw = diff --relative --color-words
  dicwa = diff --relative --color-words=\".\"
  dicwmb = diff --relative --color-words=\"[^ ,|]+\"
  ds = !git --no-pager diff --stat
  dc = diff --cached --relative
  dccw = diff --cached --relative --color-words
  dccwa = diff --cached --relative --color-words=\".\"
  dccwmb = diff --cached --relative --color-words=\"[^ ,|]+\"
  dcs = !git --no-pager diff --cached --stat
  dw = whatchanged -p
  dwcw = whatchanged -p --color-words
  dil = diff @{1}
  sh = show
  shst = !git --no-pager show --stat
  shcw = show --color-words
  shcwa = show --color-words=\".\"
  shcwmb = show --color-words=\"[^ ,|]+\"
  lol = log --graph --decorate --pretty=oneline --abbrev-commit --date=relative
  lola = log --graph --decorate --pretty=oneline --abbrev-commit --date=relative --all
  lops = log -p -S
  lsi = ls-files --others -i --exclude-standard
  au = add -u
  ai = add --interactive
  ap = add --patch
  rmc = rm --cached
  rb = rebase
  rbi = rebase -i
  rba = rebase --abort
  rbc = rebase --continue
  rbs = rebase --skip
  me = merge
  ms = merge --squash
  mt = mergetool -y
  cp = cherry-pick
  cpn = cherry-pick -n
  fp = format-patch
  fpp = format-patch --stdout
  prb = pull --rebase
  grn = grep -n
  grn5 = grep -nC5
  grn10 = grep -nC10

When typing a git command you can press tab to auto complete or show the list of possible completions.

Refer to an existing git tutorial on the internet for command line usage: it is more powerful for advanced users, but I don't expect there will be enough people wanting to use it for making a specific PW tutorial to be worthwhile.
 
Back
Top Bottom