Created
March 14, 2013 10:53
-
-
Save dcunited001/5160447 to your computer and use it in GitHub Desktop.
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
| #wm git | |
| gitbruser() { | |
| git branch $2 | | |
| grep "$1" | | |
| sed "s/^.*\\($1\\/.*\\)$/\\1/"; } | |
| gbrdc() { gitbruser dc $1 } | |
| gbrsdc() { gbrdc --no-merged | rgs git checkout -=-=; } | |
| gwip() { | |
| gwipname=${1:-wip}-`date +%s` | |
| git add -A; | |
| git ls-files --deleted -z | | |
| xargs -0 -I {} git rm {}; | |
| git commit -m $gwipname; | |
| echo $gwipname; } | |
| grewip() { | |
| git log -n 1 | | |
| grep -q -c $1 && | |
| git reset HEAD~1; } | |
| gcurbr-ref(){ git symbolic-ref -q HEAD; } | |
| gcurbr() { git rev-parse --abbrev-ref HEAD; } | |
| gtrybe() { | |
| # shell functions don't work with xargs | |
| # tries to rebase; saves WIP branch; | |
| # always resets, but rebase will stick | |
| # if there's no conflicts | |
| gtrybr=$1 | |
| gtryhead=$2 | |
| git checkout $gtrybr | |
| git rebase $gtryhead; # assume gtrybr has fetched/pulled | |
| if [ "$?" -ne 0 ]; then | |
| git rebase --abort | |
| echo Resetting `gcurbr`: couldnt rebase $gtrybr. | |
| fi; | |
| } | |
| gbrsync() { | |
| if [ $# -eq 0 ] ; then | |
| echo 'user branch folder required (e.g. dc)' | |
| return 0 | |
| fi | |
| gbsfolder=$1 | |
| gbsremote=${2:-origin} | |
| gbshead=${3:-master} | |
| # WIP_saved against the current branch | |
| gbscur=$(gcurbr) | |
| gbswip=$(gwip) | |
| # TODO: backup branches? | |
| git checkout $gbshead | |
| git fetch $gbsremote | |
| git pull $gbsremote $gbshead | |
| # TODO: split up into multiple functions 4 xargs | |
| gitbruser $gbsfolder --no-merged | | |
| xargs -I -=-= sh -c "git checkout -=-=; git rebase $gbshead; if [ \"\$?\" -ne 0 ]; then git rebase --abort; fi;" | |
| gch $gbscur | |
| grewip $gbswip; | |
| } | |
| # haven't tested these yet | |
| gitlist() { xargs -I -=-= sh -c "git checkout -=-=; $@"; } | |
| gls() { | |
| # swap $1 & $2? | |
| git branch $2 | | |
| grep "$1" | | |
| sed "s/^.*\\($1\\/.*\\)$/\\1/"; } | |
| glstatus() { gls | gitlist "git status"; } | |
| glspull() { | |
| glspattern=$1 | |
| glsremote=$2 | |
| # TODO: filter out the local and up to date branches | |
| gls $glspattern | gitlist "git pull $glsremote -=-="; } | |
| # gbrpsync() { | |
| # if [ $# -eq 0 ] ; then | |
| # echo 'user branch folder required (e.g. dc)' | |
| # return 0 | |
| # fi | |
| # gbsfolder=$1 | |
| # gbsremote=${2:-origin} | |
| # gbshead=${3:-master} | |
| # # WIP_saved against the current branch | |
| # gbscur=$(gcurbr) | |
| # gbswip=$(gwip) | |
| # TODO: find all branches that need updates from remote | |
| # TODO: pull all updates from remote | |
| # } | |
| # gpushall() { | |
| # if [ $# -eq 0 ] ; then | |
| # echo 'user branch folder required (e.g. dc)' | |
| # return 0 | |
| # fi | |
| # gbsfolder=$1 | |
| # gbsremote=${2:-origin} | |
| # gbshead=${3:-master} | |
| # gbscur=$(gcurbr) | |
| # TODO: find all branches that need updates | |
| # TODO: push all branches that need to be udpated | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment