-
-
Save DamolAAkinleye/020cab8d1700ef51a4bab20a81e14e6b to your computer and use it in GitHub Desktop.
zsh with git flow
This file contains 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
# depends on justin808 gist named utility.zsh | |
# https://gist.github.com/justin808/bdef67f37c2cbdba898a | |
# See forum discussion: http://forum.railsonmaui.com/t/zsh-with-git-flow/135 | |
#### GIT #### | |
# http://superuser.com/questions/458906/zsh-tab-completion-of-git-commands-is-very-slow-how-can-i-turn-it-off | |
# fix slow completion on files | |
# __git_files () { | |
# _wanted files expl 'local files' _files | |
# } | |
# http://notes.envato.com/developers/rebasing-merge-commits-in-git/ | |
# https://gist.github.com/590895 | |
function git_current_branch() { | |
git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///' | |
} | |
alias gpthis='git push origin HEAD:$(git_current_branch) && git branch -u origin/$(git_current_branch) $(git_current_branch) && echo "pushed current branch and set upstream to origin"' | |
alias s='git status --short' | |
alias gh='git log --name-status -n' | |
alias gm='git merge --no-ff' | |
alias gl='git log' | |
alias gs='git stash' | |
alias grhard='git reset --hard' | |
alias grsoft='git reset --soft' | |
git-branch-current() { | |
printf "%s\n" $(git branch 2> /dev/null | grep -e ^* | tr -d "\* ") | |
} | |
git-log-last-pushed-hash() { | |
local currentBranch=$(git-branch-current); | |
git log --format="%h" -n 1 origin/${currentBranch} | |
} | |
git-rebase-unpushed() { | |
git rebase --interactive $(git-log-last-pushed-hash) | |
} | |
gitk_everything() { | |
gitk --all --date-order $(git log -g --pretty=%H) | |
} | |
gitFlowNameForCurrentBranch() { | |
# next line using sed is greedy | |
# git_current_branch | sed -e 's/.*\///' | |
# This is the non-greedy match | |
git_current_branch | perl -pe "s|.*?/||" | |
} | |
alias gfn=gitFlowNameForCurrentBranch | |
gup_develop() { | |
current_branch="$(git_current_branch)" | |
echo current_branch is $current_branch | |
gco develop && gup && gco "$current_branch" | |
} | |
gup_master() { | |
current_branch="$(git_current_branch)" | |
echo current_branch is $current_branch | |
gco master && gup && gco "$current_branch" | |
} | |
gup_develop_master() { | |
gup_develop && gup_master | |
} | |
gffs() { | |
feature=`sanitize $1` | |
gup_develop_master && echoRun "git flow feature start -F --showcommands $feature" | |
} | |
gffp() { | |
feature=`sanitize $1` | |
gup_develop_master && echoRun "git flow feature publish --showcommands $feature" | |
} | |
gfff() { | |
gup_develop_master && echoRun "git flow feature finish -F --showcommands $(gitFlowNameForCurrentBranch)" && | |
echo "Confirm merge and then push develop" || echo "Examine error messages!" | |
} | |
gfrs() { | |
release=`sanitize $1` | |
gup_develop_master && echoRun "git flow release start -F --showcommands $release" | |
} | |
gfrp() { | |
release=`sanitize $1` | |
gup_develop_master && echoRun "git flow release publish -F --showcommands $release" | |
} | |
# Changed to | |
# 1. Be sure to sync up remotes and pull --rebase | |
# 2. Not push | |
gfrf() { | |
gup_develop_master && echoRun "git flow release finish -Fn --showcommands $(gitFlowNameForCurrentBranch)" && | |
echo "Confirm merge and then push master" || echo "Examine error messages!" | |
} | |
gfhs() { | |
release=`sanitize $1` | |
gup_develop_master && echoRun "git flow hotfix start -F --showcommands $release" | |
} | |
gfhp() { | |
release=`sanitize $1` | |
gup_develop_master && echoRun "git flow hotfix publish --showcommands $release" | |
} | |
# Changed to | |
# 1. Be sure to sync up remotes and pull --rebase | |
# 2. Not push | |
gfhf() { | |
gup_develop_master && echoRun "git flow hotfix finish -Fn --showcommands $(gitFlowNameForCurrentBranch)" && | |
echo "Confirm merge and then push master and develop" || echo "Examine error messages!" | |
} | |
alias git-diff-master-develop='git log --left-right --graph --cherry-pick master..develop' | |
alias git-cleanup-merged-branches='git branch --merged develop | grep -v develop | xargs git branch -d' | |
alias git-cleanup-origin='git remote prune origin' | |
alias git-cleanup-octopress-merged-branches='git branch --merged source | grep -v source | grep -v master | xargs git branch -d' | |
git-list-remote-branches-to-remove() { | |
git branch -r --merged | grep 'origin/' | grep -v "origin/master$" | grep -v "origin/develop$" | sed 's/\s*origin\///' | |
} | |
git-list-remote-branches-to-remove-do-it() { | |
git-list-remote-branches-to-remove | xargs -n 1 git push --delete origin | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment