Skip to content

Commit b9a745f

Browse files
jroperhelmo
authored andcommitted
Added --force option to push
manually merged for whitespace reasons.
1 parent 00b1b9f commit b9a745f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

git-subtree.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ b,branch= create a new branch from the split subtree
3131
ignore-joins ignore prior --rejoin commits
3232
onto= try connecting new tree to an existing one
3333
rejoin merge the new branch back into HEAD
34+
options for 'push'
35+
f,force use force push
3436
options for 'add', 'merge', 'pull' and 'push'
3537
squash merge subtree changes as a single commit
3638
"
@@ -89,6 +91,7 @@ while [ $# -gt 0 ]; do
8991
-b) branch="$1"; shift ;;
9092
-P|--prefix) prefix="$1"; shift ;;
9193
-m) message="$1"; shift ;;
94+
-f|--force) force=1 ;;
9295
--no-prefix) prefix= ;;
9396
--onto) onto="$1"; shift ;;
9497
--no-onto) onto= ;;
@@ -781,10 +784,16 @@ cmd_push()
781784
repository=$(git config -f .gittrees subtree.$prefix.url)
782785
refspec=$(git config -f .gittrees subtree.$prefix.branch)
783786
fi
787+
788+
push_opts=
789+
if [ "$force" == "1" ]; then
790+
push_opts="$push_opts --force"
791+
fi
792+
784793
echo "git push using: " $repository $refspec
785794
rev=$(git subtree split --prefix=$prefix)
786795
if [ -n "$rev" ]; then
787-
git push $repository $rev:refs/heads/$refspec
796+
git push $push_opts $repository $rev:refs/heads/$refspec
788797
else
789798
die "Couldn't push, 'git subtree split' failed."
790799
fi

git-subtree.txt

+7
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@ OPTIONS FOR split
278278
'--rejoin' when you split, because you don't want the
279279
subproject's history to be part of your project anyway.
280280

281+
OPTIONS FOR push
282+
----------------
283+
-f::
284+
--force::
285+
Uses 'git push --force'.
286+
287+
281288

282289
EXAMPLE 1. Add command
283290
----------------------

0 commit comments

Comments
 (0)