I just started on a new project and I'm using GitLab with SourceTree. I had created a branch (origin\master) but I did the mistake of using this branch for my development, so I pushed my first few changes to this branch. Now I learned that this branch should actually have the production version and that an origin\develop branch should be used for development.
Is there any way I can rename the master branch to origin\develop and somehow create a new origin\master branch with the original version of the application?
I'm the only developer in the project so it won't affect anyone. If possible, if you can explain how to do it in SourceTree since I don't use the command line git. I'm more familiar with SourceTree.
The steps to change a git branch name are: Rename the Git branch locally with the git branch -m new-branch-name command. Push the new branch to your GitHub or GitLab repo. Delete the branch with the old name from your remote repo.
You created a new branch , pushed the changes to the remote repository, and realized that your branch name was incorrect. Luckily, Git allows you to rename the branch very easily using the git branch -m command.
You could try something like this. Answer modified from this great answer, to suit OP's needs.
git branch -m master develop # rename master on local git push origin :master # delete master on remote git push origin develop # create develop on remote git checkout -b master develop # create a new local master on top of develop git push origin master # create master on remote
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With