0

I created a branch on local git which worked on it successfully and committed to GitHub.

I am the only one working on this branch. The Jira name for which this branch is created is fine and spelled correctly. So basically the branch was named XYZ_ADDONDENTS as opposed to the correct spelling of XYZ_ADDONDETS. Therefore a redundant character "N" has been added. Everything is fine. Someone spotted the mistake and reminded me.

Now the question is what is the easiest way of renaming this branch at local and the corresponding branch it GitHub? Given that on the face of it, this is cosmetic and it is bound to happen again, is there a simple proven process to remedy it. The other alternative is to leave it as is and in the GitHub make a reference to the correct spelling of the branch. The reasoning would be that branches are temporal and should not matter what they ae called.

Appreciate any advice.

Mich Talebzadeh
  • 117
  • 2
  • 12

1 Answers1

1
# Renaming the local branch
git branch -m <old-name> <new-name>

# Deleting the old branch on remote(ex. origin)
git push <remote> --delete <old-name>


# Unsetting upsteam  
git branch --unset-upstream <old-name>

# Push the new branch to remote
git push <remote> <new-name>

# Resetting the upstream branch for the new-name
git push <remote> -u <new-name>
rajnikant7008
  • 76
  • 2
  • 10
  • Thanks This is what normally I normally do for pushing to GitHub git push --set-upstream origin so substitute origin for remote in above lines? And for renaming can I do it when I am already on or do I need to go to another branch say git branch – Mich Talebzadeh Aug 25 '21 at 19:49
  • You can rename branch from , delete the from remote and push the ! – rajnikant7008 Aug 26 '21 at 13:16