Skip to content

Instantly share code, notes, and snippets.

@dccampbell
Last active January 14, 2020 03:22
Show Gist options
  • Save dccampbell/5c7e6c72c8ec09a35ff2 to your computer and use it in GitHub Desktop.
Save dccampbell/5c7e6c72c8ec09a35ff2 to your computer and use it in GitHub Desktop.
[core]
autocrlf = input
eol = lf
[push]
default = current
[pull]
ff = only
[merge]
ff = false
[diff]
compactionHeuristic = true
[alias]
co = checkout
cfg = config --global -e
puff = pull --ff-only
force = push --force-with-lease
rename = branch -m
amend = commit --amend --no-edit
amend-msg = commit --amend
curr = rev-parse --abbrev-ref HEAD
track = branch --set-upstream-to
track-curr = !git branch --set-upstream-to origin/"$(git rev-parse --abbrev-ref HEAD)"
commit-all = !git add --all && git commit
amend-all = !git add --all && git commit --amend --no-edit
branches = for-each-ref --format=%(refname:short) refs/heads/
aliases = !git config --get-regexp '^alias\\.' | sed -e 's/^alias\\.//' -e 's/\\ /\\ =\\ /' | sort
tag-delete = "!f() { git tag -d $@; for tag in $@; do git push origin :refs/tags/$tag; done; }; f"
changes = show --stat --oneline
graph = log --color --decorate --date=short --graph --pretty=format:'%h | %ad | %an | %s%d'
hist = log --color --decorate --date=relative --pretty=format:'%C(yellow)%h %C(green)%ad%C(red)%d %C(reset)%s%C(blue) [%cn]%C(reset)'
greplog = log --oneline --grep
lastmsg = log -1 --pretty=%B
compare = log --left-right --cherry-pick --oneline --no-merges
compare-hashes = "!f() { git compare $@ | tac | cut -d' ' -f2; }; f"
apply-ignorespacing = apply --ignore-space-change --ignore-whitespace
diff-ignorespacing = diff --ignore-space-change --ignore-all-space --ignore-space-at-eol --ignore-blank-lines
find-lost = "!git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d' ' -f3 | xargs -n1 git log -n1 --pretty=oneline"
[user]
name = David C. Campbell
email = david@dccampbell.com
[core]
autocrlf = input
safecrlf = false
editor = nano
excludesfile = ~/.gitignore_global
[push]
default = current
[pull]
ff = only
[merge]
ff = false
[rebase]
autosquash = true
[pager]
log = cat
[diff]
compactionHeuristic = true
[alias]
co = checkout
cfg = config --global -e
puff = pull --ff-only
force = push --force-with-lease
rename = branch -m
eol = ls-files --eol
amend = commit --amend --no-edit
amend-msg = commit --amend
curr = rev-parse --abbrev-ref HEAD
commit-all = !git add --all && git commit
amend-all = !git add --all && git commit --amend --no-edit
track = branch --set-upstream-to
untrack = branch --unset-upstream
track-curr = !git branch --set-upstream-to origin/"$(git rev-parse --abbrev-ref HEAD)"
dev = checkout develop
master = checkout master
hard = reset --hard
hardm = reset --hard origin/master
reset-other = branch -f
reset-other-co = "!f() { git branch -f $1; git checkout $1; }; f"
amend-date = "!f() { date=\"${1:-$(date -d now )}\"; GIT_COMMITTER_DATE=\"$date\" git commit --amend --date=\"$date\"; }; f"
amend-date-keep = "!f() { date=\"${1:-$(git log -1 --format=%cI)}\"; GIT_COMMITTER_DATE=\"$date\" git commit --amend; }; f"
amend-date-authoriscommitter = "!f() { date=\"${1:-$(git log -1 --format=%cI)}\"; git commit --amend --date=\"$date\"; }; f"
amend-date-committerisauthor = "!f() { date=\"${1:-$(git log -1 --format=%aI)}\"; GIT_COMMITTER_DATE=\"$date\" git commit --amend; }; f"
get-date = log -1 --format=%aI
get-date-committed = log -1 --format=%cI
redate = rebase --committer-date-is-author-date
status-all = for-each-ref --format="%(refname:short) %(push:short) %(push:track)" refs/heads
merge-msgdefault = "!f() { git merge -m \"Merge branch '${1#origin/}'\" -- $1; }; f"
merge-rebase = "!f() { curr=$(git curr) && git checkout $1 && git rebase $curr && git checkout $curr && git merge-msgdefault $1; }; f"
merge-rebase-master = "!f() { curr=$(git curr) && git checkout $1 && git rebase master && git checkout $curr && git merge-msgdefault $1; }; f"
branches = for-each-ref --format=%(refname:short) refs/heads/
aliases = !git config --get-regexp '^alias\\.' | sed -e 's/^alias\\.//' -e 's/\\ /\\ =\\ /' | sort
start = !git init && git commit -m "Initial Commit" --allow-empty
save = !git add --all && git commit -m 'fixup! SAVEPOINT'
wipe = !git add --all && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
reset-attr = !git rm .gitattributes && git add -A && git reset --hard
tag-delete = "!f() { git tag -d $@; for tag in $@; do git push origin :refs/tags/$tag; done; }; f"
tag-amend-msg = "!f() { GIT_COMMITTER_DATE=\"$(git get-date $1)\" GIT_COMMITTER_NAME=\"$(git log -1 --format=%aN $1)\" git tag -f -a $1 $1^{}; }; f"
tag-delete-msg = "!f() { git tag -f $1 $1^{}; }; f"
changes = show --stat --oneline
lol = log --graph --decorate --pretty=oneline --abbrev-commit
graph = log --graph --decorate --pretty=format:'%h | %ad | %an | %s%d' --date=short
hist = log --color --decorate --pretty=tformat:'%C(yellow)%h %C(green)%ar %C(reset)%s %C(blue)[%cn]%C(red)%d%C(reset)'
hist-dates = log --color --decorate --pretty=tformat:'%C(yellow)%h %C(green)%aI %C(reset)%s %C(blue)[%cn]%C(red)%d%C(reset)'
changelog = log --pretty=tformat:'- %h %s'
greplog = log --oneline --grep
lastmsg = log -1 --pretty=%B
compare = log --left-right --cherry-pick --oneline --no-merges
compare-hashes = "!f() { git compare $@ | tac | cut -d' ' -f2; }; f"
filesizes = "!git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print substr($0,6)}' | sort --numeric-sort --key=2 | cut --complement --characters=13-40 | numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest"
apply-ignorespacing = apply --ignore-space-change --ignore-whitespace
diff-ignorespacing = diff --ignore-space-change --ignore-all-space --ignore-space-at-eol --ignore-blank-lines
diff-ignorespacing-files = diff --ignore-space-change --ignore-all-space --ignore-space-at-eol --ignore-blank-lines --name-only
TAIL = !git rev-list HEAD | tail -n1 # returns oldest hash in commit list (opposite of rev-parse HEAD)
diff-all = "!git diff-ignorespacing HEAD..$(git TAIL)"
diff-all-files = "!git diff-ignorespacing-files HEAD..$(git TAIL)"
list-features = !git for-each-ref --format='%(refname:short)' --sort='committerdate' refs/heads/ | grep 'feature/'
list-merged = !git branch -r --merged | grep -E 'feature|hotfix|release' | cut -d"/" -f2-
list-hidden = !git ls-files -v | grep '^[Ss]'
prune-all = "!rm -rf .git/refs/original/ && git reflog expire --expire=now --all && git gc --aggressive --prune=now"
find-lost = "!git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d' ' -f3 | xargs -n1 git log -n1 --pretty=oneline"
change-author="!echo \"filter-branch --env-filter 'GIT_AUTHOR_NAME=\\\"New Name\\\"; GIT_AUTHOR_EMAIL=newemail@example.com' master..HEAD\""
skiptree = update-index --skip-worktree
skiptree-off = update-index --no-skip-worktree
stsh = stash --keep-index # stash only unstaged changes to tracked files
#stash = stash # stash any changes to tracked files
staash = stash --include-untracked # stash untracked and tracked files
staaash = stash --all # stash ignored, untracked, and tracked files
### OS ###
.DS_Store
.DS_Store?
.AppleDouble
.LSOverride
Thumbs.db
ehthumbs.db
Desktop.ini
*.lnk
*~
### Editors ###
.idea/
.vscode/
*.iml
*.ipr
*.iws
nbproject/
nbbuild/
nbdist/
.project
.buildpath
~$*.doc*
~$*.xls*
.~lock.*
*.cache
*.sublime-*
*.tmp
*.bak
*.swp
*~.nib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment