Skip to content

Instantly share code, notes, and snippets.

@riaancornelius riaancornelius/.gitconfig Secret
Last active Nov 16, 2016

What would you like to do?
name = Riaan Cornelius
email = RiaanC@***
# Use Notepad++ as editor of choice
editor = /c/dev/npp/notepad++ -multiInst -nosession
autocrlf = true
# list all aliases
la = "!git config -l | grep alias | sort | cut -c 7-"
a = add
A = add -A # Add all
aa = add --all # Add all
ae = add --edit # Open the diff vs. the index in an editor and let the user edit it. After the editor was closed, adjust the hunk headers and apply the patch to the index.
ai = add --interactive # Add modified contents in the working tree interactively to the index.
ap = add --patch # Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.
au = add --update # Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to match the working tree, but adds no new files.
# runs through all uncommitted changes, prompting to keep or revert
keepp = !sh -c 'git reset && git add -p && git stash save --keep-index && git stash drop && git reset' -
# stash all unstaged changes
unstagestash = stash -u -k
b = branch
bm = branch -m
co = checkout # Switch branch
cob = checkout -b # Create branch and check it out immediately
cot = checkout -t # Checkout the specified remote branch with tracking and guessing the name by looking at the local part of the refspec
go = checkout -B # switch to a branch, creating it if necessary
# update origin/ references. useful for finding deleted branches
update = remote prune origin
# tag and delete the specific branch
deletebranch = !sh -c 'git checkout $1 && git tag HEAD_$1 && git push origin :$1 && git checkout master && git branch -D $1' -
c = commit
ca = commit --amend
cm = commit --message
changes = diff --name-status -r # Show filenames for all changed files
d = !"d() { git_quick_diff_with_number_from_status_changed $1; }; d" # Show the diff between the the current state and the latest commit
dc = diff --cached # show diff of changes in index
dt = difftool
f = fetch
fu = fetch upstream
# Logs with tree structure
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
# one line logs
l = log --oneline --decorate
ls = log --pretty=format:"%Cgreen%h\\ %C(yellow)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# list of all commit messages, in chronological order
changelist = log --pretty=format:"%s" --reverse
# search for a term inside changesets
find = !sh -c 'git log -G$1 --pretty=format:"%Cgreen%h\\%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate' -
# display the latest annotated tag
showtag = !sh -c 'git describe --tags --abbrev=0 --match=$1' -
# list commits that have not yet been pushed to the remote
unpushed = log --branches --not --remotes --oneline
# list all commits made in the last day by yourself
standup = "!git lg --all --since yesterday --author ` git config --global --get`"
# list all files that are currently ignored by git
ignored = ls-files --others -i --exclude-standard
# list all branches that has been merged into this one
merged = !sh -c 'git fetch -p && git branch -a --merged' -
# List all authors on this repo with the number of commits by each
authors = "!git log --pretty=format:%aN | sort | uniq -c | sort -rn"
# list all tags matching the argumment, with their dates
chrontag = !sh -c 'git tag -l $1 | xargs -I@ git log --date=short --format=format:\"%ad @%n\" -1 @ | sort -r ' -
# list the branch you are currently on
on = !sh -c 'git rev-parse --abbrev-ref HEAD' -
# list all branches that was last modified in the previous month
stale = !sh -c 'git branchblame | grep -v `date +%Y-%m`' -
ls-ignored = ls-files --exclude-standard --ignored --others
tree = log --graph --pretty=oneline --decorate
m = merge
mm = merge --no-ff
mt = mergetool
# resolve merge conflicts and continue a rebase
mtr = !git mt && git rebase --continue
prune-remotes = "!for remote in `git remote`; do git remote prune $remote; done"
r = rebase
reb = !"r() { git rebase --autosquash -i HEAD~$1; }; r" # Interactive rebase with the given number of latest commits
s = status --short --branch
# Temporarily stop tracking a file in git.
# usage: git unwatch path/to/file
unwatch = update-index --assume-unchanged
# usage: git watch path/to/file
# Resume tracking a file in git.
watch = update-index --no-assume-unchanged
# clear the unwatched list
watchall = "!git unwatched | xargs -L 1 -I % sh -c 'git watch `echo % | cut -c 2-`'"
# List all unwatched files
unwatched = !git ls-files -v | grep "^[[:lower:]]" | awk '{print $2}'
undo = reset --soft HEAD^
# show all branches that was last modified (month-2) months ago
showold = "!git for-each-ref refs/remotes --format='%(committerdate:short) %(authorname) %(refname:short)' | grep origin | grep -vE '(HEAD|master)' | grep -v `date +%Y-%m` | grep -v `date --date=\"$(date +%Y-%m-15) -1 month\" +'%Y-%m'`"
# delete all branches that showold returned
deleteold = "!git showold | xargs -L 1 -I % sh -c 'git deletebranch `echo % | cut -c 19-`'"
# lists all remote branches with the time last changed and the person who made the change
branchblame = "!git for-each-ref --format='%(committerdate:iso8601) %09 %(authorname) %09 %(refname)' | sort | grep origin"
# same as branchblame, but for tags
tagblame = "!git for-each-ref --format='%(authorname) %09 %(refname) %09 %(committerdate)' | sort -k5n -k2M -k3n -k4n | grep tags "
# list all branches that was last modified in the previous month
stale = !sh -c 'git branchblame | grep -v `date +%Y-%m`' -
# Delete local branches that isn't on remote anymore
du = !sh -c 'git branch -d $(git branch --merged) && git remote prune origin'
# start mergetool and don't prompt before each file
mt = mergetool --no-prompt
# cherry-pick allowing empty commits
# c = cherry-pick --allow-empty
# continue with a previously started cherry-pick
# cc = cherry-pick --continue --allow-empty
# abort a cherry-pick that is in progress
# ca = cherry-pick --abort
default = current
tool = intellij
[mergetool "intellij"]
cmd = /c/dev/idea/bin/idea.bat merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = true
tool = intellij
[difftool "intellij"]
cmd = /c/dev/idea/bin/idea.bat diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")
template = ~/commit-template.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.