Skip to content

Instantly share code, notes, and snippets.

@farynaio
Last active April 22, 2020 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farynaio/ebba9034f372d29fe6ce29687ff45934 to your computer and use it in GitHub Desktop.
Save farynaio/ebba9034f372d29fe6ce29687ff45934 to your computer and use it in GitHub Desktop.
47 Git Aliases That Will Make You More Productive
[alias]
  # list all aliases
  la = "!git config -l | grep alias | cut -c 7-"
  # log as graph tree
  ls = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all --branches
  # formated log with stats
  ll = log --pretty=format:'* %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --decorate --numstat --all --branches
  # log as series of patches
  fl = log -p
  # grep over the log and return commit and files
  fi = log --all --pretty=\"format:%Cgreen%H %Cblue%s%Creset\" --name-status --grep
  # formated, colored reflog
  rl = reflog --pretty=format:\"%Cred%h%Creset %C(auto)%gd%Creset %C(auto)%gs%C(reset) %C(green)(%cr)%C(reset) %C(bold blue)<%an>%Creset\" --abbrev-commit
  # add all files to index and stage
  a = add --all
  # add all file to index and stage with patch mode
  ap = add --all -p
  # show diff of the given revision
  dr  = "!f() { git diff "$1"^.."$1"; }; f "
  # find file path in code base
  f = "!git ls-files | grep -i "
  # search code base for string
  gr = grep -Ii 
  # amend last commit
  cia = commit --amend --reuse-message=HEAD --edit -v -q
  # commit
  ci = commit -v -q
  # assume unchanded for single file
  assume = update-index --assume-unchanged
  # unassume unchanded for single file
  unassume = update-index --no-assume-unchanged
  # list all assume unchanged files
  assumed = "!git ls-files -v | grep ^h | cut -c 3-"
  # unassume all assume unchanged files
  unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged"
  # show last tag
  lt = describe --tags --abbrev=0
  re = remote
  rev = remote -v
  rp = replace --format=long
  pl = pull
  ps = push
  pst = push --tags
  cp = cherry-pick
  st = status -s
  fe = fetch
  fea = fetch -a
  ci = commit
  co = checkout
  br = branch
  brr = branch -r
  di = diff
  diff = diff
  dc = diff --cached HEAD^
  r = reset
  r1 = reset HEAD^
  r2 = reset HEAD^^
  ss = stash
  # list all stashes in nice colo format
  sl = stash list --pretty=format:\"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %<(70,trunc)%s %C(green)(%cr) %C(bold blue)<%an>%C(reset)\"
  sd = stash show -p
  mt = mergetool
  dt = difftool
  sub = submodule
  # update all modules to most recent versions
  subu = submodule update --recursive --remote --merge
  # find parent branch for current branch
  parent = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #"
  # show details of last commit
  sh = show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment