Last active
July 26, 2019 06:21
-
-
Save kristofk/e78d896807382732f9fc01a553da44eb to your computer and use it in GitHub Desktop.
Renames the current branch and locally and on remote. (gitrenamebransh.sh <remote_name> <old_branch_name> <new_branch_name>)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Calling this script: | |
# gitrenamebransh.sh <remote_name> <old_branch_name> <new_branch_name> | |
# Rename the local branch to the new name | |
git branch -m $2 $3 | |
# Delete the old branch on remote - where <remote> is, for example, origin | |
git push $1 --delete $2 | |
# Push the new branch to remote | |
git push $1 $2 | |
# Reset the upstream branch for the new_name local branch | |
git push $1 -u $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://stackoverflow.com/questions/30590083/how-do-i-rename-both-a-git-local-and-remote-branch-name?answertab=votes#tab-top