diff --git a/bin/git-sync b/bin/git-sync index 49fe98f..682c286 100755 --- a/bin/git-sync +++ b/bin/git-sync @@ -7,10 +7,11 @@ function _usage() Usage: ${command} [ ] ${command} -h | --help + ${command} -s | --soft Sync local branch with /. When and 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." diff --git a/man/git-sync.1 b/man/git-sync.1 index 30ec48e..67c5981 100644 --- a/man/git-sync.1 +++ b/man/git-sync.1 @@ -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 [ ] +\fBgit sync\fR [\-\-soft] [ ] . .SH "DESCRIPTION" Sync local branch with /\. @@ -16,7 +16,13 @@ Sync local branch with /\. When and 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> . diff --git a/man/git-sync.html b/man/git-sync.html index ab00335..f4ad81f 100644 --- a/man/git-sync.html +++ b/man/git-sync.html @@ -56,6 +56,7 @@ NAME SYNOPSIS DESCRIPTION + OPTIONS EXAMPLES AUTHOR REPORTING BUGS @@ -75,7 +76,7 @@

SYNOPSIS

-

git sync [ <remote> <branch> ]

+

git sync [--soft] [ <remote> <branch> ]

DESCRIPTION

@@ -83,7 +84,13 @@

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

@@ -97,9 +104,14 @@
$ git sync origin master
 
+

Sync without cleaning untracked files:

+ +
$ git sync -s origin master
+
+

AUTHOR

-

Written by Takuma Yamaguchi <kumon0587@gmail.com>

+

Written by Takuma Yamaguchi <kumon0587@gmail.com>

REPORTING BUGS

@@ -112,7 +124,7 @@
  1. -
  2. October 2017
  3. +
  4. January 2019
  5. git-sync(1)
diff --git a/man/git-sync.md b/man/git-sync.md index f2f6e43..9854353 100644 --- a/man/git-sync.md +++ b/man/git-sync.md @@ -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 <>