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
cdf = clean -df
cge = config --global --edit
cgl = config --global --list
ccd = clean -n -d
st = status
cim = commit -m
clr = reset --hard
cp = cherry-pick
cxd = clean -xfd
br = branch
df = diff
diff-changes = diff --name-status -r
gmm = merge main
gdm = diff --name-only main...
gss = stash show -p
last = log -1 HEAD --stat
rba = branch -r
rod = push origin --delete
rpb = push --set-upstream origin
rfp = fetch --prune
sw = switch
undo = reset HEAD~1 --mixed
unstage = reset HEAD --
staged = diff --cached
unstaged = diff
both = diff HEAD
amend = commit --amend
lg = log --graph --pretty=format:'%D(auto) %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
ll = log --oneline
lol = log --graph --decorate --pretty=oneline --abbrev-commit
# lol = log --graph --decorate --pretty=format:'%C(auto)%h %C(red)%as %C(blue)%aN%C(auto)%d%C(green) %s'
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
lon = log --name-only
ls = ls-files
structure = log --graph --pretty=format:'%h %s' --abbrev-commit --date=relative --name-only
slog = log --pretty=format:'%D %C(auto)%h %C(red)%as %C(blue)%aN%C(auto)%d%C(green) %s'
# put = push origin HEAD
# track = !git-trackw
# 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