[英]How to migrate a file and all its commit history to a new repo in git?
I have a repo (repoA) and a file in that repo has 20-30 commits; 我有一个仓库(repoA),该仓库中的文件有20-30次提交; I want to move that file to repoB with all of the commit history;
我想将该文件与所有提交历史记录一起移到repoB; how do I do that?
我怎么做?
If what you want to move is the whole branch as it is, just add a new remote pointing to the new repo and push the branch to it. 如果要移动的是整个分支,则只需添加指向新仓库的新远程对象,然后将分支推入该分支即可。 If you have 30 commits with say 50 files and you want to move the history of a "single" file, as if the file was always alone you will have to rewrite the history of the branch so that you get only the history of that file, no more and then you will add the remote and then push to it.
如果您有30个提交(例如50个文件),并且想要移动“单个”文件的历史记录,就好像该文件始终是单独的一样,则您将不得不重写分支的历史记录,以便仅获取该文件的历史记录,再也没有了,然后您将添加遥控器,然后将其推入。
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
As I understand you want to move changes only from one file and save the history of all repository. 据我了解,您只想移动一个文件中的更改并保存所有存储库的历史记录。
Commits in git aren't about some file. git中的提交与某些文件无关。 They are about repository.
它们是关于存储库的。
Maybe you can do something like: 也许您可以执行以下操作:
1)get file changes from repoA and copy them in repoB as new commit. 1)从repoA获取文件更改,并将其作为新提交复制到repoB中。
2)after some time push repoB into master for example 2)例如一段时间后将repoB推入master
3)merge master with repoA. 3)将主服务器与repoA合并。 Resolve conflicts if any.
解决冲突(如果有)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.