mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
feat(create-branch): add optional --from to set the start point
This commit is contained in:
parent
18bcfcd38e
commit
41732e4113
|
|
@ -20,6 +20,12 @@ do
|
|||
REMOTE=origin
|
||||
fi
|
||||
;;
|
||||
--from)
|
||||
if [[ -n $2 ]]; then
|
||||
START_POINT=$2
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
BRANCH=$1
|
||||
esac
|
||||
|
|
@ -44,9 +50,15 @@ then
|
|||
rm -f "$stderr"
|
||||
if [ $REMOTE_EXIT -eq 0 ]
|
||||
then
|
||||
git push $REMOTE HEAD:refs/heads/$BRANCH
|
||||
git fetch $REMOTE
|
||||
git checkout --track -b $BRANCH $REMOTE/$BRANCH
|
||||
if [[ -n $START_POINT ]]; then
|
||||
git fetch $REMOTE
|
||||
git checkout --track -b $BRANCH $START_POINT
|
||||
git push $REMOTE HEAD:refs/heads/$BRANCH
|
||||
else
|
||||
git push $REMOTE HEAD:refs/heads/$BRANCH
|
||||
git fetch $REMOTE
|
||||
git checkout --track -b $BRANCH $REMOTE/$BRANCH
|
||||
fi
|
||||
exit $?
|
||||
else
|
||||
echo
|
||||
|
|
@ -56,4 +68,9 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
git checkout -b $BRANCH
|
||||
if [[ -n $START_POINT ]]
|
||||
then
|
||||
git checkout -b $BRANCH $START_POINT
|
||||
else
|
||||
git checkout -b $BRANCH
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue