Merge in dirty changes more safely
[socialgit.git] / bin / changebranch
blobb8e347a8fff4e749656d6aed2d5bf9fbdf7e1807
1 #!/bin/sh
2 # changebranch
4 CURBRANCH=`currentbranchname`
5 if [ "$CURBRANCH" = "$1" ]; then
6 exit
7 fi
9 if (( $(git diff HEAD | wc -l) > 0 )); then
10 git branch $CURBRANCH.dirty
11 git checkout $CURBRANCH.dirty
12 echo "stashing dirty working copy" | git commit -a -F -
15 git fetch
16 git checkout -b $1 origin/$1
17 git checkout $1
19 if [ `git branch | grep $1.dirty` ]; then
20 git merge $CURBRANCH.dirty
21 git branch -D $1.dirty
22 git reset HEAD^
25 # HOOK
26 HOOK_POST_CHANGE_BRANCH=./`git rev-parse --show-cdup`.socialgit/hooks/post-change-branch
27 ls $HOOK_POST_CHANGE_BRANCH 2>/dev/null && $HOOK_POST_CHANGE_BRANCH