Skip to content

Loading…

Added --force option for doing a git push --force #11

Open
wants to merge 1 commit into from

2 participants

@jroper

No description provided.

@helmo

Unfortunately apenwarr has not been active lately.
I've merged your commit in my master branch on https://github.com/helmo/git-subtree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 27, 2012
  1. @jroper

    Added --force option to push

    jroper committed
Showing with 13 additions and 1 deletion.
  1. +8 −1 git-subtree.sh
  2. +5 −0 git-subtree.txt
View
9 git-subtree.sh
@@ -25,6 +25,8 @@ b,branch= create a new branch from the split subtree
ignore-joins ignore prior --rejoin commits
onto= try connecting new tree to an existing one
rejoin merge the new branch back into HEAD
+ options for 'push'
+f,force use force push
options for 'add', 'merge', 'pull' and 'push'
squash merge subtree changes as a single commit
"
@@ -83,6 +85,7 @@ while [ $# -gt 0 ]; do
-b) branch="$1"; shift ;;
-P) prefix="$1"; shift ;;
-m) message="$1"; shift ;;
+ -f|--force) force=1 ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
--no-onto) onto= ;;
@@ -700,10 +703,14 @@ cmd_push()
if [ $# -ne 2 ]; then
die "You must provide <repository> <refspec>"
fi
+ if [ -e "$dir" ]; then
+ push_opts=
+ if [ "$force" == "1" ]; then
+ push_opts="$push_opts --force"
fi
repository=$1
refspec=$2
- echo "git push using: " $repository $refspec
+ echo "git push using: " $repository $refspec
git push $push_opts $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
else
die "'$dir' must already exist. Try 'git subtree add'."
View
5 git-subtree.txt
@@ -254,6 +254,11 @@ OPTIONS FOR split
'--rejoin' when you split, because you don't want the
subproject's history to be part of your project anyway.
+OPTIONS FOR push
+----------------
+-f::
+--force::
+ Uses 'git push --force'.
EXAMPLE 1. Add command
----------------------
Something went wrong with that request. Please try again.