Git aliases keep you in the zone
Git aliases turns clunky terminal tasks into quick, two or three letter shortcuts that keep you in the zone.
As a general rule, I create an alias for an action I use frequently, and I try not to create an alias for destructive/deletion or complex actions; things I want to manage carefully.
To use these, add them to your global .gitconfig file, then you can access them in the terminal for any project. Remember you will still need to type “git” in order to run an alias.
These are my go-to favorites for saving time and keeping things organized (there’s even one for editing the global gitconfig file in your IDE):
[user]
name = First Last
email = hello@email.com
[credential]
helper = store
[alias]
cam = commit -am
cfg = config --list
co = checkout
cb = checkout -b
st = status
cim = commit -m
clr = reset --hard
cdf = clean -df
ccd = clean -n -d
cxd = clean -xfd
br = branch
df = diff
diff-changes = diff --name-status -r
cp = cherry-pick
rba = branch -r
cge = config --global --edit
pod = push origin --delete
rpb = push --set-upstream origin
rfp = fetch --prune
undo = reset HEAD~1 --mixed
unstage = reset HEAD --
staged = diff --cached
unstaged = diff
both = diff HEAD
#online = log --pretty=online
amend = commit --amend
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
lon = log --name-only
ls = ls-files
# put = push origin HEAD
# track = !git-track
# thanks = !git-thanks
# workdir = !git-new-workdir
# up = !git pull --rebase && git push
# ignored = "!git ls-files --others --exclude-standard"
# nb = checkout -b
# pending = !git --no-pager log origin/master..master && echo
# db = !sh -c 'git branch -D "$0" && git push origin ":$0"' &> /dev/null
# missing = !sh -c 'git cherry "$0" | cut -sd + -f 2 | xargs "git show"'
# lc = log ORIG_HEAD.. --stat --no-merges
# conflicts = !git ls-files --unmerged | cut -c51- | sort -u | xargs $EDITOR
# resolve = !git ls-files --unmerged | cut -c51- | sort -u | xargs git add
# subadd = !sh -c 'git submodule add $(git config -f"$0".git/config remote.origin.url) "$0"'
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = auto
[color "branch"]
current = green
local = magenta
remote = cyan
[color "diff"]
whitespace = red reverse
meta = yellow bold
frag = magenta
old = red
new = green
[color "status"]
added = green
changed = yellow
untracked = cyan
[format]
#numbered = auto
[push]
#default = tracking
[core]
editor = code --wait