简体   繁体   English

Git:你如何打破与原始回购的关系?

[英]Git: How do you fork with the intention of breaking ties with the original repo?

I'd like to fork a repo with the intention of breaking ties with the original repo. 我想分一个回购集团打算与原始回购破坏关系。 There will be no pull requests or any future merges whatsoever. 没有任何拉动请求或任何未来的合并。 The new repo will have a new project name. 新的仓库将有一个新的项目名称。 The only reason I don't copy the source files and start an entirely new repo from scratch is because I'd like to preserve the commit history. 我不复制源文件并从头开始一个全新的repo的唯一原因是因为我想保留提交历史记录。 How do I do this? 我该怎么做呢?

Clarification : I do use Github. 澄清 :我确实使用Github。 I wasn't previously aware that there was anything Github-specific. 我以前没有意识到Github特有的东西。 For my specific needs, I have a git repo that houses two separate projects (one Scala, one Java). 根据我的具体需求,我有一个git repo,它包含两个独立的项目(一个Scala,一个Java)。 The files for the two projects have started interfering with each other, so I'm going to fork the repo, and in the new repo delete all the files for the Scala project. 这两个项目的文件已经开始相互干扰,所以我要分配repo,并在新的repo中删除Scala项目的所有文件。 In the original repo, I'll delete all the files for the Java project. 在原始仓库中,我将删除Java项目的所有文件。

If you plan to keep everything (or almost everything) from the original project, I would just fork it as normal and begin modifying it heavily. 如果你计划保留原始项目中的所有内容(或几乎所有内容),我会正常分叉并开始大量修改它。

If you only want a small subset of the files, you could use filter-branch to remove parts of the repository you don't want from the entire history. 如果您只需要一小部分文件,则可以使用filter-branch从整个历史记录中删除您不需要的部分存储库。 This step will change every commit SHA and make it impossible to pull or merge (at least automatically) from the original. 此步骤将更改每个提交SHA,并使其无法从原始提取或合并(至少自动)。 It's not necessary to do this, though. 但是,没有要这样做。

If you are worried about accidental cross-project contamination you could use the filter-branch step just to ensure the history is incompatible, even if you are keeping most of the files. 如果您担心意外的跨项目污染,您可以使用filter-branch步骤,以确保历史记录不兼容,即使您保留大部分文件。 If there's nothing to delete, you could do something as simple as rewriting the commit message of the initial commit. 如果没有什么可以删除,你可以做一些简单的事情,如重写初始提交的提交消息。

If this is a github question, I think what you'd have to do is clone the repo to your local machine, create a new project on github (rather than forking the original) and then push to the new project. 如果这是一个github问题,我认为您需要做的是将repo克隆到本地机器,在github上创建一个新项目(而不是分配原始项目),然后推送到新项目。 Github won't figure out the relationship, as far as I know. 据我所知,Github不会弄清楚这种关系。 But if you're worried, there's still filter-branch between the initial clone and the push. 但是如果你担心,在初始克隆和推送之间仍然存在filter-branch

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

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