是否有可能将一堆文件从一个git存储库移动到另一个,同时保留(大部分)历史记录? [英] Is it possible to move a bunch of files from one git repository to another while preserving (most) history?

查看:302
本文介绍了是否有可能将一堆文件从一个git存储库移动到另一个,同时保留(大部分)历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一些文件添加到了错误的存储库中,直到后来才意识到,一旦它们已经有相当多的历史(只是线性修订,没有分支或任何东西)。



是否有可能将这些文件和它们的历史一起移动到另一个git存储库?我不在乎他们的残余物是否保留在当前的残留物中,只要新的残留物具有这一切。

解决方案

使用 git log -p< filename> > < patchfile> (请参阅文档),您可以导出该文件的整个历史可以通过 git apply --reverse --index< patchfile> 应用于其他repo。但是,这不会重新创建提交,并且我还没有弄清楚用于 git-apply 的开关来做到这一点。



如果您想摆脱原始回购中的文件,请参阅我如何从git的历史记录中删除敏感文件?


I added some files to the wrong repository and didn't realize until later, once they already had quite a bit of history (just linear revisions, no branching or anything).

Is it possible to get these files and move them to another git repository together with their history? I don't care if their remnants stay in their current one or not, as long as the new one has it all.

解决方案

With git log -p <filename> > <patchfile> (see doc) you can export the whole history of the file which can then be applied to the other repo via git apply --reverse --index <patchfile>. However this does not recreate the commits, and I haven't figured out the switch for git-apply to do this.

If you want to get rid of the file in the original repo, see "How do I remove sensitive files from git’s history?".

这篇关于是否有可能将一堆文件从一个git存储库移动到另一个,同时保留(大部分)历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆