-
-
Save ziwon/36a753a6da46c475fcf9ec0065b09af2 to your computer and use it in GitHub Desktop.
GIT & GitFlow aliases for ~/.gitconfig
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
# GIT aliases for ~/.gitconfig file | |
# @author Grzegorz Korba <[email protected]> | |
# Credits: Miscellaneous places on the Internet... | |
# GitFlow related sections | |
[gitflow "branch"] | |
master = master | |
develop = develop | |
[gitflow "prefix"] | |
feature = feature/ | |
release = release/ | |
hotfix = hotfix/ | |
bugfix = bugfix/ | |
support = support/ | |
versiontag = v | |
# Alias section. | |
[alias] | |
# List available aliases | |
la = !git config -l | grep alias | cut -c 7- | |
# Make file executable (chmod +x) | |
exec = "!f() { if [ -f $1 ]; then git update-index --chmod=+x --add $1; else echo 'Invalid file'; exit 1; fi; }; f" | |
# Some base commands | |
cp = cherry-pick | |
st = status -s | |
cl = clone | |
ci = commit | |
co = checkout | |
br = branch -v | |
diff = diff --word-diff | |
dc = diff --cached | |
# List range of commits in human-readable way | |
devnotes = "!f() { if [ ! -z $1 ] && [ ! -z $2 ]; then git log --date=short --stat --pretty='format:[%ad %C(cyan)%aN%Creset] %s %b' --abbrev-commit $1..$2; else echo 'Invalid from/to'; exit 1; fi; }; f" | |
dn = !git devnotes | |
relnotes = "!f() { if [ ! -z $1 ] && [ ! -z $2 ]; then git log --pretty='format:[%C(cyan)%aN%Creset @ %C(yellow)%h%Creset] %s %b' --abbrev-commit $1..$2 --no-merges; else echo 'Invalid from/to'; exit 1; fi; }; f" | |
rn = !git relnotes | |
# Version tags and log commands | |
lv = "!f() { VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag || echo ''); TAGS_LIST=$(git rev-list --tags=$VERSION_PREFIX'[0-9].[0-9]*' --max-count=1 2>&1); S=$?; if [[ $S = 0 ]]; then git describe --tags $TAGS_LIST; else echo 'No version tags found'; exit 1; fi; }; f" | |
av = !git describe --abbrev=0 | |
ll = log --pretty=format:%C(yellow)%h\\ %Cblue[%cn]%Cred%d\\ %Creset%s --decorate --numstat | |
ls = log --pretty=format:%C(yellow)%h\\ %Cblue[%cn]%Cred%d\\ %Creset%s --decorate | |
ld = log --pretty=format:%C(yellow)%h\\ %Cblue[%cn,\\ %ad]%Cred%d\\ %Creset%s --decorate --date=short | |
lc = "!f() { if [ ! -z $1 ] && [ ! -z $2 ]; then git ll $1^..$1; else echo 'Invalid from/to'; exit 1; fi; }; f" | |
diffr = "!f() { if [ ! -z $1 ] && [ ! -z $2 ]; then git diff $1^..$1; else echo 'Invalid from/to'; exit 1; fi; }; f" | |
dr = !git diffr | |
f = !git ls-files | grep -i | |
lasttag = describe --tags --abbrev=0 | |
lt = !git lasttag | |
# Ignoring files locally | |
assume = "!f() { if [ -f $1 ]; then git update-index --assume-unchanged $1; else echo 'Invalid file'; exit 1; fi; }; f" | |
unassume = "!f() { if [ -f $1 ]; then git update-index --no-assume-unchanged $1; else echo 'Invalid file'; exit 1; fi; }; f" | |
assumed = !git ls-files -v | grep '^[[:lower:]]' | cut -c 3- | |
ignored = !git assumed | |
unassumeall = !git assumed | xargs git update-index --no-assume-unchanged | |
uaa = !git unassumeall | |
assumeall = !git st -s | awk {'print $2'} | xargs git assume | |
aa = !git assumeall | |
# Stash commands | |
ss = "!git stash save" | |
sp = "!git stash pop" | |
sa = "!git stash apply" | |
sl = "!git stash list" | |
sc = "!git stash clear" | |
# Tags commands | |
ft = "!git fetch --tags" | |
pt = "!git push --tags" | |
# Basic navigation | |
cm = "!git checkout master" | |
mm = "!git merge master" | |
cd = "!git checkout develop" | |
md = "!git merge develop" | |
# GitFlow shortcuts | |
fid = !git flow init -d | |
# "fcb" alias is a shortcut for getting current branch for GitFlow (without prefix) | |
# and is strictly related to [gitflow "prefix"] config section (cuts everything after first "/") | |
fcb = "!f() { git rev-parse --abbrev-ref HEAD | cut -d'/' -f 2-; }; f" | |
cf = "!f() { git checkout $(git config --get gitflow.prefix.feature || echo feature)$1; }; f" | |
ffs = "!f() { if [ ! -z $1 ] ; then git flow feature start $1 ${2:-master}; else echo 'Invalid name'; exit 1; fi; }; f" | |
fff = !git flow feature finish -F $(git fcb) | |
ffp = !git flow feature publish $(git fcb) | |
cb = "!f() { git checkout $(git config --get gitflow.prefix.bugfix || echo bugfix)$1; }; f" | |
fbs = "!f() { if [ ! -z $1 ] ; then git flow bugfix start $1 ${2:-master}; else echo 'Invalid name'; exit 1; fi; }; f" | |
fbf = !git flow bugfix finish -F $(git fcb) | |
fbp = !git flow bugfix publish $(git fcb) | |
ch = "!f() { git checkout $(git config --get gitflow.prefix.hotfix || echo hotfix)$1; }; f" | |
fhs = "!f() { if [ ! -z $1 ] ; then git flow hotfix start $1 ${2:-master}; else echo 'Invalid name'; exit 1; fi; }; f" | |
fhf = "!git fetch --tags; git pull $(git config --get gitflow.origin || echo origin) master; git flow hotfix finish -F $(git fcb)" | |
fhp = !git flow hotfix publish $(git fcb) | |
cr = "!f() { git checkout $(git config --get gitflow.prefix.release || echo release)$1; }; f" | |
frs = "!f() { if [ ! -z $1 ] ; then git flow release start $1 ${2:-master}; else echo 'Invalid name'; exit 1; fi; }; f" | |
frf = !git flow release finish -F $(git fcb) | |
frp = !git flow release publish $(git fcb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment