1

I have a repository in Github with two branches, master and dd. I gave the name dd by mistake and I want to change this name to something else from the Github GUI.

I didn't find a way to do so in the branch webpage:

https://github.com/user/repo/tree/dd

nor in the branches option page (I do have an option to change what will be the default branch):

https://github.com/user/repo/settings/branches

How could a branch name be changed in Github?

I work with the command line but yet to have learn Git in a serious way.

Osi
  • 1
  • 3
  • 9
  • 30
  • 2
    Possible duplicate of [How to rename a remote git branch name](https://stackoverflow.com/questions/30590083/how-to-rename-a-remote-git-branch-name) – Raghava Dhanya Jan 16 '18 at 13:51

4 Answers4

0

Don't know exactly how to solve it in GitHub, but locally you just can: (Assuming that same repo is locally cloned)

Rename locally:

repo (master)$ git branch -m dd new-name

Delete remote branch:

repo (master)$ git push origin :dd

Push all branches again (including the renamed one):

repo (master)$ git push --all
Mauricio Machado
  • 613
  • 1
  • 5
  • 14
0
git branch -m old-name new-name

look at this link for more details:

https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/

Ariel Braun
  • 86
  • 1
  • 8
0

You could create a new branch from dd via the Branches dropdown:

creating a new branch from develop

And then delete the old dd branch afterwards from the Branches page:

deleting the old branch

Adil B
  • 14,635
  • 11
  • 60
  • 78
0

What I did in the end was this:

First, I duplicated all the data from the wrongly named nonmaster branch to a new, rightly named nonmaster branch, and committed. I double checked that data was committed successfully and indeed there.

Second, after making sure the data was backed up, I navigated to:

https://github.com/user/repo/branches

I then used the bin icon near the name of the relevant branch and did the rest of the short deleting process from there.

Osi
  • 1
  • 3
  • 9
  • 30