Created
March 9, 2016 16:44
-
-
Save kingbin/275c6dfd7d6ae074628c to your computer and use it in GitHub Desktop.
gitconfig alias
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
[alias] | |
sub-init = "!init() { git checkout master && git pull && git submodule update --init --recursive; }; init" | |
sub-up = "!up() { git submodule foreach git checkout master && git pull; }; up" | |
sub-diff = "!diff() { git submodule foreach 'echo $path `git diff`'; }; diff;" | |
springcleaning = for-each-ref --sort=-committerdate --format='%(refname:short) %(committerdate:short)' | |
unstage = reset HEAD -- | |
pu = !="git fetch origin -v; git fetch upstream -v; git merge upstream/master" | |
vim = !.git/hooks/vim | |
br = branch | |
# show all branches, even across remotes | |
branches = branch -a --color -v | |
# remove all local branches included in the current branch | |
cleanup = !sh -c 'git branch --merged | grep -E "^[^*]" --exclude "^\\s*master" | xargs -n1 git branch -d' | |
co = checkout | |
ctags = !.git/hooks/ctags | |
# Show the diff between the latest commit and the current state | |
d = !"git diff-index --quiet HEAD -- || clear; git diff --patch-with-stat" | |
#delete local & remote branches | |
del = "!f() { echo deleting remote $1 && git push origin --delete $1 && echo deleting local $1 && git branch -D $1; }; f"; | |
# `git di $number` shows the diff between the state `$number` revisions ago and the current state | |
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" | |
# Diff | |
df = diff | |
dt = "!d() { git diff-tree --no-commit-id --name-only -r $1; }; d" | |
# Get short SHA-1 for object | |
hash = rev-parse --short HEAD | |
lc = log ORIG_HEAD.. --stat --no-merges | |
# just for fun | |
l33t = !"git shortlog | l33t" | |
last = log -1 HEAD | |
lol = log --abbrev-commit --pretty=format:'%h - %an, %ad : %s' --graph | |
lola = log --abbrev-commit --pretty=format:'%h - %an, %ad : %s' --graph --all | |
loln = log --abbrev-commit --pretty=format:'%h - %an, %ad : %s' --graph --name-status | |
ls = ls-files | |
# depends on hub | |
mypulls = browse -- pulls/kingbin | |
# Find FIXME, TODO, etc, optimized by @x3ro https://gist.github.com/3908985 | |
n = !"f() { git ls-files $1 | xargs notes | awk -F: '{ print $1,$2; print $3,$4; print $5}' | grcat conf.notes | less -r; }; f" | |
pullm = !"git pull origin master" | |
pushm = !"git push origin master" | |
rb = rebase | |
rbc = rebase --continue | |
# Interactive rebase with the selected number of latest commits | |
reb = "!r() { git rebase -i HEAD~$1; }; r"tags = tag -l | |
# track a remote branch | |
track = checkout -t | |
st = status | |
# update all submodules | |
subs = submodule foreach git pull origin master | |
# clean up fully merged branches | |
sweep = !git-sweep | |
# list only untracked files | |
untracked = ls-files --others --exclude-standard | |
# remove a file from the index | |
unstage = reset HEAD -- | |
up = "!git remote update -p; git merge --ff-only @{u}" | |
wdiff = diff --color-words | |
visual = !gitk | |
#stash functions | |
sshow = "!f() { git stash show stash^{/$*} -p; }; f" | |
ssave = "!f() { git stash save $*; }; f" | |
sapply = "!f() { git stash apply stash^{/$*}; }; f" | |
statust = "!f() { git status -uno; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment