Created
March 27, 2020 20:57
-
-
Save denniswon/4263af3f52c9052d2e9ac0f3b784a2a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
excludesfile = /Users/denniswon/.gitignore | |
[filter "lfs"] | |
clean = git-lfs clean -- %f | |
smudge = git-lfs smudge -- %f | |
process = git-lfs filter-process | |
required = true | |
[alias] | |
rs = reset | |
co = checkout | |
br = branch | |
ci = commit | |
st = status | |
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
list = ls-tree --name-only -r HEAD | |
# Logic: | |
# | |
# The 'git stash save' fails if the tree is clean (instead of | |
# creating an empty stash :P). So, we only 'stash' and 'pop' if | |
# the tree is dirty. | |
# | |
# The 'git rebase --whitespace=fix HEAD~' throws away the commit | |
# if it's empty, and adding '--keep-empty' prevents the whitespace | |
# from being fixed. So, we first check that the index is dirty. | |
# | |
# Also: | |
# - '(! git diff-index --quiet --cached HEAD)' is true (zero) if | |
# the index is dirty | |
# - '(! git diff-files --quiet .)' is true if the tree is dirty | |
# | |
# The 'rebase --whitespace=fix' trick is from here: | |
# https://stackoverflow.com/a/19156679/470844 | |
fixws = !"\ | |
if (! git diff-files --quiet .) && \ | |
(! git diff-index --quiet --cached HEAD) ; then \ | |
git commit -m FIXWS_SAVE_INDEX && \ | |
git stash save FIXWS_SAVE_TREE && \ | |
git rebase --whitespace=fix HEAD~ && \ | |
git stash pop && \ | |
git reset --soft 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" | |
[user] | |
name = Dennis Won | |
email = [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment