Skip to content

Instantly share code, notes, and snippets.

@kmorcinek
Last active February 27, 2022 18:45
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save kmorcinek/5747081 to your computer and use it in GitHub Desktop.
Save kmorcinek/5747081 to your computer and use it in GitHub Desktop.
Add it to ".gitconfig" file in your user directory. Configuration & aliases for git.
[core]
# autocrlf = true/input # it should be done explicit using .gitattributes https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings
[pull]
rebase = true
[push]
default = current
[alias]
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%an]" --decorate
lst = log --pretty=format:%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%an] --decorate -10
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cgreen\\ [%an]" --decorate --date=short
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%an]" --decorate --numstat
lol = log --graph --decorate --pretty=oneline --abbrev-commit --all
cp = cherry-pick
st = status -s
ci = commit
co = checkout
br = branch
diff = diff --word-diff
wdiff = diff --word-diff=plain
dc = diff --cached
r = reset
r1 = reset HEAD^
rh = reset --hard
rh1 = reset --hard HEAD^
rh2 = reset --hard HEAD^^
ready = rebase -i @{u}
amend = commit --amend -aC HEAD
undo = reset --soft HEAD^
#clean = add . && git rh
# standup = log --since '1 day ago' --oneline --author <YOUREMAIL> # hack it with your email and uncomment
# jira = log --since '6am' --oneline --author <YOUREMAIL> # hack it with your email and uncomment
# git-svn
spull = svn rebase
spush = svn dcommit
# even faster aliases
aa = add --all
com = checkout master
cam = commit -am
ac = !git add -A && git commit
acam = !git add -A && git commit -am
ri2 = rebase -i HEAD~2
ri3 = rebase -i HEAD~3
ri5 = rebase -i HEAD~5
ri9 = rebase -i HEAD~9
ri22 = rebase -i HEAD~22
ri = rebase -i
rc = rebase --continue
ra = rebase --abort
rs = rebase --skip
mt = mergetool
ref1 = reset --hard HEAD@{1}
ref2 = reset --hard HEAD@{2}
cv = checkout - # checkout on previous branch, faster to type than 'cb'
rem = rebase master
syncm = !git checkout master && git pull --rebase && git checkout - && git rebase master
riom = rebase -i origin/master # rebase origin/master
cppb = cherry-pick HEAD@{1} # Cherry-pick previous branch
pushf = push --force-with-lease
revh = revert HEAD
fp = fetch --prune
# Two aliases below are from https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote/28464339#28464339
brprune = remote prune origin
brclean = !git branch --merged >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
# Some common commit messages
dead = commit -am 'Remove dead code'
readme = commit *.md -m'Just update readme'
# Add files based on extension
cs = add *.cs
js = add *.js
ts = add *.ts
sql = add *.sql
json = add *.json
java = add *.java
yml = add *.yml
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = c:/Program Files/KDiff3/kdiff3.exe
[diff]
tool = kdiff3
guitool = kdiff3
[difftool "kdiff3"]
path = c:/Program Files/KDiff3/kdiff3.exe
[mergetool]
keepBackup = false
[fetch]
prune = true
[color]
ui = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment