From: Michael Hart <>

If the subtree split fails it doesn't return the SHA that should be
pushed to the other repository.

Added a check to ensure that split succeeds before trying to push
and display an error message.

Signed-off-by: Paul Campbell <>
 contrib/subtree/ | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/ b/contrib/subtree/
index 8a23f58..c68cc6f 100755
--- a/contrib/subtree/
+++ b/contrib/subtree/
@@ -715,7 +715,12 @@ cmd_push()
            echo "git push using: " $repository $refspec
-           git push $repository $(git subtree split 
+           rev=$(git subtree split --prefix=$prefix)
+           if [ -n "$rev" ]; then
+               git push $repository $rev:refs/heads/$refspec
+           else
+               die "Couldn't push, 'git subtree split' failed."
+           fi
            die "'$dir' must already exist. Try 'git subtree add'."

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to