简体   繁体   English

归档Github Master分支并删除Master分支中的所有文件

[英]Archive Github Master Branch and Delete All Files in Master Branch

I'm trying to do what is described here:我正在尝试执行此处描述的操作:

Move master branch to another branch and start new master 将 master 分支移动到另一个分支并启动新的 master

I have new "Upgraded" project files that I want to replace all the files currently in the master branch.我有新的“升级”项目文件,我想替换当前在master分支中的所有文件。

I've copied the master branch to a archive branch and now I need to reset / delete all the files in the master branch and then sync that with Github.我已经将 master 分支复制到archive分支,现在我需要重置/删除 master 分支中的所有文件,然后将其与 Github 同步。

I've tried running : 我试过跑步

git push origin :master

Which tries to delete the master branch but I get this message:它试图删除主分支但我收到此消息:

To github.com:fireflysemantics/validatorts.git
 ! [remote rejected] master (refusing to delete the current branch: refs/heads/master)
error: failed to push some refs to 'github.com:fireflysemantics/validatorts.git'

So do we delete the master branch and sync the deletion to Github?那我们是不是删除master分支,同步删除到Github呢? Then recreate the master branch and sync the new one with the new files?然后重新创建主分支并将新分支与新文件同步?

You can do this in a simple and straightforward way, that takes multiple steps:您可以通过简单直接的方式执行此操作,这需要多个步骤:

  • Pick or create a new branch to be used as the default.选择或创建一个新分支作为默认分支。
  • Use the GitHub web interface (or the API) to set this as the default branch.使用 GitHub web 接口(或 API)将此设置为默认分支。

You can now delete master as you have been attempting.您现在可以像您尝试的那样删除master Then you can create a new master , and, if you wish, use the GitHub web interface (or API) to set the new master as the default branch.然后您可以创建一个新的master ,并且,如果您愿意,可以使用 GitHub web 接口(或 API)将新的master设置为默认分支。

Alternatively, you can use git push --force origin new_master:master .或者,您可以使用git push --force origin new_master:master This may or may not succeed, depending on what push rights you have, but if it does succeed, it will make GitHub use your new_master branch as its master branch.这可能会或可能不会成功,具体取决于拥有的推送权限,但如果成功,它将使 GitHub 使用您的new_master分支作为其master分支。 Remember, the names of branches in your Git repository need not match the names of branches in any other Git repository , including the one on GitHub.请记住,您的Git 存储库中的分支名称不需要与任何其他 Git 存储库中的分支名称匹配,包括 GitHub 上的分支名称。

You can rename your own branches at any time.您可以随时重命名自己的分支。 Your branch names are yours .你的分支名称是的。 Their branch names are theirs .他们的分支名称是他们的 Just because you and they both have a branch name xyzzy does not mean these are the "same branch" in any useful sense: they are the same if and only if you decree that they are the same, otherwise they are different.仅仅因为你和他们都有一个分支名称xyzzy并不意味着它们在任何有用的意义上都是“相同的分支”:当且仅当你规定它们相同时它们是相同的,否则它们是不同的。 We (humans) tend to try to use the same names on "both sides" to maintain our sanity, of course, but that's not a requirement.当然,我们(人类)倾向于尝试在“双方”使用相同的名字以保持我们的理智,但这不是必需的。 1 1个


1 Which of these is not a requirement? 1以下哪一项不是必需的? Keeping the same names, or being sane?保持相同的名字,还是保持理智? That's for you to decide.那是你来决定的。

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

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