简体   繁体   English

如何在保留旧母版作为分支的同时将新母版制作为分支?

[英]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. 我有一个项目,在其中我以两种不同的方式构建电子商务网站,一种使用react,另一种仅使用vanilla js。 currently the vanilla branch is master and the react branch is called react-version. 目前,香草分支是master分支,而react分支称为react-version。 I would like to switch them and make the react-version the master and vanilla can be called vanillajs-version. 我想切换它们并使react-version为master和vanilla,可以称为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: 如此答案中的建议, 在git中切换分支名称 ,我能够在本地存储库中切换名称,但是当我尝试推送到远程时,我收到一条错误消息:

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. 错误:无法将一些引用推送到“ https://github.com/tito300/Elegant-TK-FullStack.git ”提示:由于当前分支的尖端位于其远程对应的后面,因此拒绝更新。 Integrate the remote changes (eg 'git pull ...') before pushing again. 在再次推送之前,集成远程更改(例如“ git pull ...”)。 See the 'Note about fast-forwards' in 'git push --help' for details. 有关详细信息,请参见“ git push --help”中的“关于快进的注意事项”。

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 新建一个名为vanillajs-version的分支
  2. create pull request from the master branch to vanillajs-version branch 创建从master分支到vanillajs-version分支的拉取请求
  3. Delete the contents of master branch. 删除master分支的内容。
  4. create a pull request from the react-version branch to master branch. 创建一个从react-version分支到master分支的拉取请求。
  5. delete the react-version branch or keep it as you want 删除react-version分支或根据需要保留它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git:在Github上做一个分支作为主人,同时在BitBucket上保持真正的主人 - Git: make a branch as master on Github while keeping real master on BitBucket 如何放弃旧的Git Master,并将分支用作新的Master? - How to abandon old Git Master, and use branch as new master? 如何在保留新分支中的更改的同时将本地分支合并到更新的分支中? - How to merge local branch to an updated master while keeping changes in the new master? 将旧的git分支设为master分支 - Make old git branch a master branch 如何使git分支成为新主人? - How to make a git branch the new master? 我在git的master分支中搞砸了,创建了一个新分支,如何使该分支成为新的master? - I messed up in my master branch in git, created a new branch, how to make this branch new master? SourceTree - 使分支成为新的主节点 - SourceTree - make branch the new master 如何让我的主人分支我的头,并创建一个新主人 - How to make my Master branch my Head, and create a new master 如何合并 git 中的分支,该分支一直在 master 中删除文件,同时在 master 分支中保持删除的文件完整? - How to merge branch in git which deleted files in master all the while keeping the deleted files intact in the master branch? 如何将旧提交变成主提交,将新提交变成新分支? - How to turn a old commit into master and the new ones into new branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM