We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b00aace commit 4a05ad2Copy full SHA for 4a05ad2
bin/git-rename-branch
@@ -1,11 +1,17 @@
1
#!/usr/bin/env bash
2
+set -e
3
4
# Assert there is at least one branch provided
5
test -z $1 && echo "new branch name required." 1>&2 && exit 1
6
7
new_branch="$1"
8
old_branch="${2-$(git symbolic-ref --short -q HEAD)}"
9
+remote=$(git config branch."$old_branch".remote)
10
11
git branch -m "$old_branch" "$new_branch"
-git push origin :"$old_branch"
-git push --set-upstream origin "$new_branch"
12
+# check if the branch is tracking a remote branch
13
+if [[ -n "$remote" && "$remote" != "." ]]
14
+then
15
+ git push "$remote" :"$old_branch"
16
+ git push --set-upstream "$remote" "$new_branch"
17
+fi
0 commit comments