Skip to content

Instantly share code, notes, and snippets.

@dhruv-m-patel
Last active April 5, 2022 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhruv-m-patel/8c39fb4fb9ce7332aed3647dc726cce4 to your computer and use it in GitHub Desktop.
Save dhruv-m-patel/8c39fb4fb9ce7332aed3647dc726cce4 to your computer and use it in GitHub Desktop.
Useful Git aliases
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
[push]
default = current
[alias]
a = add
cm = commit -m
co = checkout
cob = checkout -b
pr = pull --rebase
pf = push -f
logs = !git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
rbi = rebase -i
d = diff
ds = diff --stat
dc = diff --cached
st = status
sts = status -s
unstage = reset HEAD
changes = !git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit master..
purge = "!git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D"
latest = !git pull && git fetch -p && git purge
update = !git commit --amend --no-edit
comp = !git checkout master && git pull && git fetch -p && git purge
codp = !git checkout develop && git pull && git fetch -p && git purge
# list branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
# list aliases
la = "!git config -l | grep alias | cut -c 7-"
[color]
ui = true
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "diff"]
meta = 227
frag = magenta bold
commit = 227 bold
old = red bold
new = green bold
whitespace = red reverse
[core]
pager = diff-so-fancy | less --tabs=4 -RFX
[pull]
ff = only
[user]
name = <FirstName LastName>
email = <github email>
@dhruv-m-patel
Copy link
Author

For diff, run npm install diff-so-fancy -g to be pretty :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment