mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
feat: Add -s(--soft) for git sync
feat: Add readme for man page and helper fix: Remove git-sync.1.html
This commit is contained in:
parent
49fab7267b
commit
9f806bb828
15
bin/git-sync
15
bin/git-sync
|
|
@ -7,10 +7,11 @@ function _usage()
|
|||
Usage:
|
||||
${command} [<remote> <branch>]
|
||||
${command} -h | --help
|
||||
${command} -s | --soft
|
||||
|
||||
Sync local branch with <remote>/<branch>.
|
||||
When <remote> and <branch> are not specified on the command line, upstream of local branch will be used by default.
|
||||
All changes and untracked files and directories will be removed.
|
||||
All changes and untracked files and directories will be removed unless you add -s(--soft).
|
||||
|
||||
Examples:
|
||||
Sync with upstream of local branch:
|
||||
|
|
@ -18,6 +19,9 @@ Examples:
|
|||
|
||||
Sync with origin/master:
|
||||
${command} origin master
|
||||
|
||||
Sync without cleaning untracked files:
|
||||
${command} -s
|
||||
EOS
|
||||
}
|
||||
|
||||
|
|
@ -29,6 +33,9 @@ function main()
|
|||
_usage
|
||||
exit
|
||||
;;
|
||||
-s | --soft)
|
||||
local soft="true"
|
||||
;;
|
||||
* )
|
||||
if [ "${remote}" = "" ]; then
|
||||
local remote="$1"
|
||||
|
|
@ -65,7 +72,11 @@ function main()
|
|||
read res
|
||||
case "${res}" in
|
||||
"Y" | "y" | "yes" | "Yes" | "YES" )
|
||||
git fetch "${remote}" "${branch}" && git reset --hard "${remote_branch}" && git clean -d -f -x
|
||||
if [ "${soft}" = "true" ]; then
|
||||
git fetch "${remote}" "${branch}" && git reset --hard "${remote_branch}"
|
||||
else
|
||||
git fetch "${remote}" "${branch}" && git reset --hard "${remote_branch}" && git clean -d -f -x
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
echo "Canceled."
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-SYNC" "1" "October 2017" "" "Git Extras"
|
||||
.TH "GIT\-SYNC" "1" "January 2019" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-sync\fR \- Sync local branch with remote branch
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit sync\fR [ <remote> <branch> ]
|
||||
\fBgit sync\fR [\-\-soft] [ <remote> <branch> ]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Sync local branch with <remote>/<branch>\.
|
||||
|
|
@ -16,7 +16,13 @@ Sync local branch with <remote>/<branch>\.
|
|||
When <remote> and <branch> are not specified on the command line, upstream of local branch will be used by default\.
|
||||
.
|
||||
.P
|
||||
All changes and untracked files and directories will be removed\.
|
||||
All changes and untracked files and directories will be removed unless you add \-s(\-\-soft)\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
\-\-soft or \-s
|
||||
.
|
||||
.P
|
||||
Add this flag if you want to preserve untracked files\.
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
Sync local branch with its upstream
|
||||
|
|
@ -44,6 +50,19 @@ $ git sync origin master
|
|||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Sync without cleaning untracked files:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git sync \-s origin master
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Written by Takuma Yamaguchi <\fIkumon0587@gmail\.com\fR>
|
||||
.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
<a href="#NAME">NAME</a>
|
||||
<a href="#SYNOPSIS">SYNOPSIS</a>
|
||||
<a href="#DESCRIPTION">DESCRIPTION</a>
|
||||
<a href="#OPTIONS">OPTIONS</a>
|
||||
<a href="#EXAMPLES">EXAMPLES</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
|
|
@ -75,7 +76,7 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p> <code>git sync</code> [ <remote> <branch> ]</p>
|
||||
<p> <code>git sync</code> [--soft] [ <remote> <branch> ]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
|
|
@ -83,7 +84,13 @@
|
|||
|
||||
<p> When <remote> and <branch> are not specified on the command line, upstream of local branch will be used by default.</p>
|
||||
|
||||
<p> All changes and untracked files and directories will be removed.</p>
|
||||
<p> All changes and untracked files and directories will be removed unless you add -s(--soft).</p>
|
||||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p> --soft or -s</p>
|
||||
|
||||
<p> Add this flag if you want to preserve untracked files.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
|
|
@ -97,9 +104,14 @@
|
|||
<pre><code>$ git sync origin master
|
||||
</code></pre>
|
||||
|
||||
<p> Sync without cleaning untracked files:</p>
|
||||
|
||||
<pre><code>$ git sync -s origin master
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Takuma Yamaguchi <<a href="mailto:kumon0587@gmail.com" data-bare-link="true">kumon0587@gmail.com</a>></p>
|
||||
<p>Written by Takuma Yamaguchi <<a href="mailto:kumon0587@gmail.com" data-bare-link="true">kumon0587@gmail.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -112,7 +124,7 @@
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>October 2017</li>
|
||||
<li class='tc'>January 2019</li>
|
||||
<li class='tr'>git-sync(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-sync(1) -- Sync local branch with remote branch
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git sync` [ <remote> <branch> ]
|
||||
`git sync` [--soft] [ <remote> <branch> ]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
|
|
@ -11,7 +11,14 @@ git-sync(1) -- Sync local branch with remote branch
|
|||
|
||||
When <remote> and <branch> are not specified on the command line, upstream of local branch will be used by default.
|
||||
|
||||
All changes and untracked files and directories will be removed.
|
||||
All changes and untracked files and directories will be removed unless you add -s(--soft).
|
||||
|
||||
## OPTIONS
|
||||
|
||||
--soft or -s
|
||||
|
||||
Add this flag if you want to preserve untracked files.
|
||||
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
|
|
@ -23,6 +30,10 @@ git-sync(1) -- Sync local branch with remote branch
|
|||
|
||||
$ git sync origin master
|
||||
|
||||
Sync without cleaning untracked files:
|
||||
|
||||
$ git sync -s origin master
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Written by Takuma Yamaguchi <<kumon0587@gmail.com>>
|
||||
|
|
|
|||
Loading…
Reference in a new issue