mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Merge pull request #895 from vanpipy/feature/optional-start-point-when-creeate-branch
feat(#861): add optional parameter --from to set the start point
This commit is contained in:
commit
444722cf38
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ do
|
|||
--squash )
|
||||
merge_mode="--squash"
|
||||
;;
|
||||
--from )
|
||||
start_point=$2
|
||||
shift
|
||||
;;
|
||||
* )
|
||||
argv+=($1)
|
||||
;;
|
||||
|
|
@ -55,10 +59,24 @@ else
|
|||
else
|
||||
branch="$branch_prefix"/"${argv[0]}"
|
||||
fi
|
||||
if [[ -n $remote ]]
|
||||
|
||||
if [[ -n $remote ]] && [[ -z $start_point ]]
|
||||
then
|
||||
git create-branch -r $remote $branch
|
||||
else
|
||||
fi
|
||||
|
||||
if [[ -z $remote ]] && [[ -z $start_point ]]
|
||||
then
|
||||
git create-branch $branch
|
||||
fi
|
||||
|
||||
if [[ -n $remote ]] && [[ -n $start_point ]]
|
||||
then
|
||||
git create-branch -r $remote --from $start_point $branch
|
||||
fi
|
||||
|
||||
if [[ -z $remote ]] && [[ -n $start_point ]]
|
||||
then
|
||||
git create-branch --from $start_point $branch
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-CREATE\-BRANCH" "1" "June 2019" "" "Git Extras"
|
||||
.TH "GIT\-CREATE\-BRANCH" "1" "November 2020" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-create\-branch\fR \- Create branches
|
||||
|
|
@ -19,6 +19,12 @@ Creates local branch named <branchname> and optionally sets up a remote tracking
|
|||
Setup a remote tracking branch using \fBremote_name\fR\. If \fBremote_name\fR is not supplied, use \fBorigin\fR by default\.
|
||||
.
|
||||
.P
|
||||
<\-\-from [start_point]>
|
||||
.
|
||||
.P
|
||||
Setup a start point when the branch created\. If \fB\-\-from\fR is not supplied, use the current branch by default\.
|
||||
.
|
||||
.P
|
||||
<branchname>
|
||||
.
|
||||
.P
|
||||
|
|
|
|||
|
|
@ -90,6 +90,10 @@
|
|||
|
||||
<p>Setup a remote tracking branch using <code>remote_name</code>. If <code>remote_name</code> is not supplied, use <code>origin</code> by default.</p>
|
||||
|
||||
<p><--from [start_point]></p>
|
||||
|
||||
<p>Setup a start point when the branch created. If <code>--from</code> is not supplied, use the current branch by default.</p>
|
||||
|
||||
<p><branchname></p>
|
||||
|
||||
<p>The name of the branch to create.</p>
|
||||
|
|
@ -141,8 +145,8 @@ $ git create-branch -r upstream integration
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Jonhnny Weslley <<a href="mailto:jw@jonhnnyweslley.net" data-bare-link="true">jw@jonhnnyweslley.net</a>>
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>>, Brian Murrell <<a href="mailto:btmurrell@gmail.com" data-bare-link="true">btmurrell@gmail.com</a>>.</p>
|
||||
<p>Written by Jonhnny Weslley <<a href="mailto:jw@jonhnnyweslley.net" data-bare-link="true">jw@jonhnnyweslley.net</a>>
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>>, Brian Murrell <<a href="mailto:btmurrell@gmail.com" data-bare-link="true">btmurrell@gmail.com</a>>.</p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -155,7 +159,7 @@ Modified by Mark Pitman <<a href="mailto:&#x
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>June 2019</li>
|
||||
<li class='tc'>November 2020</li>
|
||||
<li class='tr'>git-create-branch(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ Creates local branch named <branchname> and optionally sets up a remote tr
|
|||
|
||||
Setup a remote tracking branch using `remote_name`. If `remote_name` is not supplied, use `origin` by default.
|
||||
|
||||
<--from [start_point]>
|
||||
|
||||
Setup a start point when the branch created. If `--from` is not supplied, use the current branch by default.
|
||||
|
||||
<branchname>
|
||||
|
||||
The name of the branch to create.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-FEATURE" "1" "April 2020" "" "Git Extras"
|
||||
.TH "GIT\-FEATURE" "1" "November 2020" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-feature\fR \- Create/Merge feature branch
|
||||
|
|
@ -28,6 +28,12 @@ use \fBbranch_prefix\fR instead of \fBfeature\fR
|
|||
Setup a remote tracking branch using \fBremote_name\fR\. If \fBremote_name\fR is not supplied, use \fBorigin\fR by default\.
|
||||
.
|
||||
.P
|
||||
<\-\-from [start_point]>
|
||||
.
|
||||
.P
|
||||
Setup a start point when the branch created\. If \fB\-\-from\fR is not supplied, use the current branch by default\.
|
||||
.
|
||||
.P
|
||||
<finish>
|
||||
.
|
||||
.P
|
||||
|
|
|
|||
|
|
@ -93,6 +93,10 @@
|
|||
|
||||
<p> Setup a remote tracking branch using <code>remote_name</code>. If <code>remote_name</code> is not supplied, use <code>origin</code> by default.</p>
|
||||
|
||||
<p> <--from [start_point]></p>
|
||||
|
||||
<p> Setup a start point when the branch created. If <code>--from</code> is not supplied, use the current branch by default.</p>
|
||||
|
||||
<p> <finish></p>
|
||||
|
||||
<p> Merge and delete the feature branch.</p>
|
||||
|
|
@ -136,9 +140,9 @@ $ git features finish dependencies</p></dd>
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Jesús Espino <<a href="mailto:jespinog@gmail.com" data-bare-link="true">jespinog@gmail.com</a>><br />
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>><br />
|
||||
Modified by Carlos Prado <<a href="mailto:carlos.prado@cpradog.com" data-bare-link="true">carlos.prado@cpradog.com</a>></p>
|
||||
<p>Written by Jesús Espino <<a href="mailto:jespinog@gmail.com" data-bare-link="true">jespinog@gmail.com</a>><br />
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>><br />
|
||||
Modified by Carlos Prado <<a href="mailto:carlos.prado@cpradog.com" data-bare-link="true">carlos.prado@cpradog.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -151,7 +155,7 @@ Modified by Carlos Prado <<a href="mailto:&
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>April 2020</li>
|
||||
<li class='tc'>November 2020</li>
|
||||
<li class='tr'>git-feature(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ git-feature(1) -- Create/Merge feature branch
|
|||
|
||||
Setup a remote tracking branch using `remote_name`. If `remote_name` is not supplied, use `origin` by default.
|
||||
|
||||
<--from [start_point]>
|
||||
|
||||
Setup a start point when the branch created. If `--from` is not supplied, use the current branch by default.
|
||||
|
||||
<finish>
|
||||
|
||||
Merge and delete the feature branch.
|
||||
|
|
|
|||
Loading…
Reference in a new issue