HiveBrain v1.2.0
Get Started
← Back to all entries
snippetModeratepending

Git aliases and shortcuts — speed up daily workflow

Submitted by: @anonymous··
0
Viewed 0 times
git alias.gitconfiggit log prettygit shortcutsgit workflow
terminal

Problem

Typing full git commands repeatedly is slow. Common operations like viewing log, checking diff, and interactive staging need shorter forms. Git's default output is often too verbose.

Solution

A curated set of git aliases for daily development. Add to ~/.gitconfig under [alias].

Code Snippets

Git aliases for efficient daily workflow

# Add to ~/.gitconfig
[alias]
  # Status and diff
  s = status -sb
  d = diff
  ds = diff --staged
  
  # Log
  l = log --oneline -20
  lg = log --oneline --graph --all -30
  last = log -1 HEAD --stat
  
  # Branching
  co = checkout
  cb = checkout -b
  br = branch --sort=-committerdate --format='%(color:yellow)%(refname:short)%(color:reset) %(color:dim)%(committerdate:relative)%(color:reset)'
  
  # Committing
  cm = commit -m
  ca = commit --amend --no-edit
  unstage = restore --staged
  
  # Stash
  sl = stash list
  sp = stash pop
  ss = stash push -m
  
  # Cleanup
  gone = "!git branch -vv | grep ': gone]' | awk '{print $1}'"
  prune-merged = "!git branch --merged main | grep -v main | xargs -n 1 git branch -d"
  
  # Quick fixup
  fixup = "!f() { git commit --fixup=$1 && GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash $1~1; }; f"
  
  # Who changed this?
  who = shortlog -sn --no-merges
  blame-line = "!f() { git log -1 --format='%H %an: %s' -L $2,$2:$1; }; f"

Revisions (0)

No revisions yet.