Skip to content

Instantly share code, notes, and snippets.

@beenhere4hours
Last active August 12, 2021 14:37
Show Gist options
  • Save beenhere4hours/533e7ee9a4a717418585 to your computer and use it in GitHub Desktop.
Save beenhere4hours/533e7ee9a4a717418585 to your computer and use it in GitHub Desktop.
Custom git configuration
[user]
name = Daniel Masi
email = beenhere4hours@gmail.com
[alias]
# lists the available aliases
ad = add
al = config --get-regexp alias
st = status
ci = commit
cim = commit -m
br = branch
bra = branch -a
co = checkout
df = diff
fapt = fetch --all -p -t
lg = log -p --stat
lgt = log --graph --simplify-by-decoration --pretty=format:'%Cred%h%Creset-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
ls = ls-files
# list sorted by most active authors
rnk = shortlog -sne
# delete all pruned branches
delbr = !git branch -d `git branch --merged | cut -c3- | grep -ve "^master$"`
# https://code.google.com/p/nathan-collins--conf/source/browse/dot.gitconfig?r=327#165
# The different cases are:
# - dirty tree and dirty index
# - dirty tree and clean index
# - clean tree and dirty index
#
# We have to consider separate cases because the 'git rebase
# --whitespace=fix' is not compatible with empty commits (adding
# '--keep-empty' makes Git not fix the whitespace :P).
fixws-global-tree-and-index = !"\
if (! git diff-files --quiet .) && \
(! git diff-index --quiet --cached HEAD) ; then \
git commit -m FIXWS_SAVE_INDEX && \
git add -u :/ && \
git commit -m FIXWS_SAVE_TREE && \
git rebase --whitespace=fix HEAD~2 && \
git reset HEAD~ && \
git reset --soft HEAD~ ; \
elif (! git diff-files --quiet .) ; then \
git add -u :/ && \
git commit -m FIXWS_SAVE_TREE && \
git rebase --whitespace=fix HEAD~ && \
git reset HEAD~ ; \
elif (! git diff-index --quiet --cached HEAD) ; then \
git commit -m FIXWS_SAVE_INDEX && \
git rebase --whitespace=fix HEAD~ && \
git reset --soft HEAD~ ; \
fi"
# highlight whitespace
[color]
ui = true
[color "diff"]
whitespace = red reverse
[core]
# this works best with your IDE settings spaces for tabs, width of 4
whitespace=fix,cr-at-eol
tabwidth=4
ignorecase = false
excludesfile = /Users/dmasi/.gitignore_global
# lets add some color
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = green
changed = yellow
untracked = red
[push]
default = current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment