简体   繁体   English

如何在没有旧提交的情况下将分支文件从旧存储库移动到新存储库

[英]How can I move branch files from an old repository to a new one without the old commits

I am creating a new pristine repository for the next generation of our product. 我正在为下一代产品创建一个新的原始存储库。 I need to use some "state" from the old repo -- similar to cherry-picking. 我需要使用旧仓库中的一些“状态”,类似于摘樱桃。 In fact, functionally it would be simply resetting to a commit on the old repo then committing the file changes to the new repository. 实际上,从功能上讲,它仅是重置为对旧存储库的提交,然后将文件更改提交给新的存储库。 I did find that I could checkout the old branch, reset --soft to the earliest commit, then commit those files. 我确实发现我可以签出旧分支,将--soft重置为最早的提交,然后提交那些文件。 But it seems like a hack. 但这似乎是一种hack。 Since I see upstream and origin as a bit of a pattern, it seems like this would not be too uncommon, although I guess most of those cases would want commits. 由于我将上游和起源看作是一种模式,因此,尽管我猜大多数情况下都需要提交,但这似乎并不太常见。

You need to do a checkout --orphan so that you go to that revision (working tree content) but have no history behind it. 您需要执行检出--orphan,以便您转到该修订版(工作树内容),但没有任何历史记录。 When you do your first commit, it will be a root commit, no history behind it. 当您进行第一次提交时,它将是一个根提交,后面没有任何历史记录。

git checkout ---orphan -b new-branch some-revision-to-get-working-tree

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

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