简体   繁体   中英

How to make a branch the new master while keeping old master as a branch?

I have a project where I am building an ecommerce website in 2 different ways, one using react and one just vanilla js. currently the vanilla branch is master and the react branch is called react-version. I would like to switch them and make the react-version the master and vanilla can be called vanillajs-version.

I have looked at some other answers but in those cases the old master is not needed while in my case it is.

Thanks!

update:

as suggested in this answer Switch branch names in git , I was able to switch name in the local repository however when I try to push to remote I get an error saying:

error: failed to push some refs to ' https://github.com/tito300/Elegant-TK-FullStack.git ' hint: Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (eg 'git pull ...') before pushing again. See the 'Note about fast-forwards' in 'git push --help' for details.

I do not want to integrate them because they are basically different implementation. I branched out very early in the project. any work around?

You can do the following steps:

  1. make a new branch named vanillajs-version
  2. create pull request from the master branch to vanillajs-version branch
  3. Delete the contents of master branch.
  4. create a pull request from the react-version branch to master branch.
  5. delete the react-version branch or keep it as you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM