Skip to content

Commit

Permalink
remote branch we found may not contain 'xxx/' if old branch is tracki…
Browse files Browse the repository at this point in the history
…ng a local one
  • Loading branch information
spacewander committed Mar 16, 2017
1 parent a4af12a commit a41e2e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/git-rename-branch
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a41e2e8

Please sign in to comment.