|
# Config shared by all installations of git (Win, Win bash and Linux). To reference this in a .gitconfig file |
|
# [include] |
|
# path = <path_to_shared_config> |
|
[user] |
|
email = |
|
name = |
|
[push] |
|
default = simple |
|
[http] |
|
sslverify = false |
|
postBuffer = 1048576000 |
|
[i18n] |
|
commitEncoding = utf-8 |
|
[gui] |
|
encoding = utf-8 |
|
# assumes the ~/.gitconfig contains [difftool "kdiff3"] and [mergetool "kdiff3"] definitions |
|
[diff] |
|
tool = kdiff3 |
|
guitool = kdiff3 |
|
[merge] |
|
tool = kdiff3 |
|
[alias] |
|
# list all aliases |
|
la = "!git config -l | grep alias | sort | cut -c 7-" |
|
# 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 |
|
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 |
|
# 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 |
|
# commit, allowing for empty commits |
|
ce = commit --allow-empty |
|
# resolve merge conflicts and continue a rebase |
|
mtr = !git mt && git rebase --continue |
|
# list all commits made in the last day by yourself |
|
standup = "!git lg --all --since yesterday --author ` git config --global --get user.email`" |
|
# list all files that are currently ignored by git |
|
ignored = ls-files --others -i --exclude-standard |
|
# update origin/ references. useful for finding deleted branches |
|
update = remote prune origin |
|
# amend the last commit made |
|
amend = commit --amend |
|
# delete the specified tag both on the local machine and the origin |
|
deltag = !sh -c 'git tag -d $1 && git push origin :refs/tags/$1' - |
|
# stage all deleted files for commit |
|
stagedeleted = "! git ls-files --deleted -z | xargs -0 git rm" |
|
# 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' - |
|
# 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 " |
|
# 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' - |
|
# list all branches that has been merged into this one |
|
merged = !sh -c 'git fetch -p && git branch -a --merged' - |
|
# stash all unstaged changes |
|
unstagestash = stash -u -k |
|
# 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`' - |
|
# List everything that changed from the previous build. Assumes that builds are tagged in the form BUILD_<number>. |
|
changeset = "!git showtag 'BUILD*' && git describe && git changelist --no-merges `git showtag 'BUILD*'`..HEAD" |
|
# print the name of the remote $1 in the form "[remote]" (no new line) if the branch $2 exists on it |
|
printremote = !sh -c '[[ $(git ls-remote $1 $2) ]] && echo -n " [$1] "' - |
|
# loop through remotes and print "[remote]" (no new line) if branch $1 exists |
|
listremotes = !sh -c 'git remote | xargs -L 1 -I % git printremote % $1' - |
|
# loop through all branches and print the remotes they exist on |
|
branchremotes = "!git branch -r | grep -v HEAD | cut -d / -f 2 | sort -u | xargs -L 1 -I % sh -c 'git listremotes %; echo %;'" |
|
# show the first 7 digits of the SHA1 for the given branch |
|
brref = !sh -c 'git show-ref $1 --hash=7' - |
|
# fetch all branches from all remotes |
|
fa = "! git remote | xargs -L 1 -t git fetch" |
|
# 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-`'" |
|
# list all remotes that has been merged into the current branch |
|
mergedremotes = "!git merged | grep remotes | grep -v HEAD | grep -v `git on`" |
|
# list all remotes that has been merged into the current branch with the person responsible |
|
mergeblame = "!git mergedremotes | xargs -L 1 -I xx git log --format='%h %<(30)%ae %<(20)%an %<(15)%ar xx' --no-walk xx" |
|
# temporarily mark file as ignored |
|
unwatch = update-index --assume-unchanged |
|
# start tracking file again |
|
watch = update-index --no-assume-unchanged |
|
# list all files that has been temporarily ignored |
|
unwatched = "!git ls-files -v | grep '^[[:lower:]]'" |
|
# clear the unwatched list |
|
watchall = "!git unwatched | xargs -L 1 -I % sh -c 'git watch `echo % | cut -c 2-`'" |
|
# clear the stash before stashing |
|
clst = "!git stash clear && git stash" |
|
# (Bitbucket specific) push and open the given Pull Request URL |
|
pr = "!git push origin `git on` --progress 2>&1 | grep remote | grep http | sed 's/^[^:]*://g' | sed 's/ //g'| xargs -L 1 -I % sh -c 'git web--browse %'" |