Skip to content

Commit a41e2e8

Browse files
committed
remote branch we found may not contain 'xxx/' if old branch is tracking a local one
1 parent a4af12a commit a41e2e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bin/git-rename-branch

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ old_branch="${2-$(git symbolic-ref --short -q HEAD)}"
88
remote="$(git for-each-ref --format='%(upstream:short)' "refs/heads/$old_branch")"
99

1010
git branch -m "$old_branch" "$new_branch"
11-
if [ -n "$remote" ]
11+
# check if the branch is tracking a remote branch
12+
if [[ -n "$remote" && "$remote" == */* ]]
1213
then
1314
remote=${remote%%/*}
1415
git push "$remote" :"$old_branch"

0 commit comments

Comments
 (0)