Skip to content

Instantly share code, notes, and snippets.

@chaoslogick
Last active October 27, 2017 16:58
Show Gist options
  • Save chaoslogick/186f15df4e5bc52b0efe to your computer and use it in GitHub Desktop.
Save chaoslogick/186f15df4e5bc52b0efe to your computer and use it in GitHub Desktop.
GIT: .gitconfig
[user]
name = Michael Perry Goodman
email = [redacted]
[filter "lfs"]
clean = git lfs clean %f
smudge = git lfs smudge %f
required = true
[core]
autocrlf = input
compression = 9
filemode = false
excludesfile = ~/.gitignore
pager = cat
editor = nano
#// Remote
[push]
default = current
[transfer]
#fsckobjects = true
[receive]
#fsckObjects = true
[fetch]
prune = true
#fsckobjects = true
#// Shortcuts
[url "https://github.com/"]
insteadOf = gh:
[url "https://gist.github.com/"]
insteadOf = gist:
#// Readability
[color]
ui = true
[color "branch"]
current = magenta
ocal = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = magenta
changed = green
untracked = red
[pager]
blame = less -S
#// Browsing
[diff]
mnemonicprefix = true
algorithm = patience
tool = meld
[difftool]
prompt = false
[grep]
extendRegexp = true
[status]
showUntrackedFiles = all
#// History
[branch]
autosetupmerge = true
autosetuprebase = always
[merge]
log = true
ff = false
[rerere]
enabled = true
[tag]
sort = version:refname
#// Git Aliases
[alias]
#// Common arguments
a = add
br = branch
ca = commit --amend
cl = clone
cm = commit -m
co = checkout
df = diff
f = fetch
i = init
lg = log --graph --pretty=format:'%Cred%h%Creset - %C(blue bold)%an%Creset: %C(cyan)%s%Creset %Cgreen(%ar)%Creset'
m = mv
sp = stash pop
sd = diff --cached
#// Update all git repos in current dir
all = "!f() { ls | xargs -I{} git -C {} $1; }; f"
#// Add and remove all changes, note how this alias is calling another alias
addremove = !git r && git add . --all
#// Show all of my configured aliases
aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ \t => \\2/' | sort
#// For when you made that commit a bit too early, amend
amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
#// Show all branches
br = branch -av
#// Show the current branch name (usefull for shell prompts)
brname = !git branch | grep "^*" | awk '{ print $2 }'
#// Delete a branch
brdel = branch -D
#// Which files are receiving the most "love"
churn = !git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count,file"} {print $1 "," $2}'
#// View the log and diff for a commit (previous if no SHA1 provided)
details = log -n1 -p --format=fuller
#// Save a repo as a tarball
export = archive -o latest.tar.gz -9 --prefix=latest/
#// Unstage changes from the index
unstage = reset HEAD --
#// View a pretty git log with branch tree
g = !git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
#// Return a list of commit SHA1s
l = "!f() { git log $* | grep '^commit ' | cut -f 2 -d ' '; }; f"
#// Remove deleted files
r = !git ls-files -z --deleted | xargs -0 git rm
#// Return the repository's root directory (usefull for shell prompts)
root = rev-parse --show-toplevel
#// Update all submodules
subup = submodule update --init --recursive
#// List all tags
tags = tag -l
#// Start a new local repository and perform initial commit
this = !git init && git add . && git commit -m \"Initial commit\"
#// Thin out older metadata within the repository, reduceses filesystem footprint
trim = !git reflog expire --expire=now --all && git gc --prune=now
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment