Skip to content

Commit f32c074

Browse files
author
Dor Kleiman
committed
Use branch name when pushing as well as pulling; imporve help message.
1 parent 5f4bd5d commit f32c074

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

git-sync

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
usage() {
66
blue "Usage"
77
cat <<-USAGE
8-
$0 [--stash] [repo[/branch]]
8+
$0 [options] [repo[/branch]]
99
Fetch, rebase, and push.
10-
--stash
11-
Saves the current status in stash before syncing, and pops afterwards.
10+
1211
repo/branch
1312
Specifies where to fetch from, pull to, and what to merge with.
13+
14+
options
15+
--stash
16+
Saves the current status in stash before syncing, and pops afterwards.
17+
18+
--rebase
19+
Uses pull --rebase instead of merge
20+
1421
USAGE
1522
exit 1
1623
}
@@ -50,12 +57,14 @@ else
5057
assert_clear_status "To stash before and after syncing, call git sync --stash"
5158
fi
5259

60+
branch="${branch/*\//}"
61+
5362
green Pulling $source $rebase
54-
git pull $rebase "$source" "${branch/*\//}" || exit 1
63+
git pull $rebase "$source" "$branch" || exit 1
5564
assert_clear_status
5665

5766
green Pushing
58-
git push "$source"
67+
git push "$source" HEAD:"$branch"
5968
assert_clear_status
6069

6170
if $stash; then

0 commit comments

Comments
 (0)