From a41e2e8849ce0cf1a2033c0c854e65ac9ee9ea3f Mon Sep 17 00:00:00 2001 From: spacewander Date: Thu, 16 Mar 2017 16:29:34 +0800 Subject: [PATCH] remote branch we found may not contain 'xxx/' if old branch is tracking a local one --- bin/git-rename-branch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/git-rename-branch b/bin/git-rename-branch index 337c48e7e..f306396a3 100755 --- a/bin/git-rename-branch +++ b/bin/git-rename-branch @@ -8,7 +8,8 @@ old_branch="${2-$(git symbolic-ref --short -q HEAD)}" remote="$(git for-each-ref --format='%(upstream:short)' "refs/heads/$old_branch")" git branch -m "$old_branch" "$new_branch" -if [ -n "$remote" ] +# check if the branch is tracking a remote branch +if [[ -n "$remote" && "$remote" == */* ]] then remote=${remote%%/*} git push "$remote" :"$old_branch"