如何从现有git存储库中的文件夹创建新的git存储库? [英] How do I create a new git repository from a folder in an existing git repository?

查看:123
本文介绍了如何从现有git存储库中的文件夹创建新的git存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在现有的git仓库下创建一个新的git仓库。我希望将历史记录保存在新的存储库中。如何创建这个新的git仓库?

解决方案

您可以克隆它,然后应用克隆过滤器分支为了拆分该存储库,只提取您想要的目录(具有完整的历史记录)。 /stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository\">将子目录放入单独的Git仓库



请注意 git clone --no-hardlinks / XYZ / ABC 在克隆步骤中使用:


- no-hardlinks 开关让git在克隆本地存储库时使用实际文件副本而不是硬链接。



I want to create a new git repository of a folder under an existing git repository. I want the history to be preserved in the new repository. How do I create this new git repository?

解决方案

You can clone it, and then apply on the clone a filter-branch in order to split that repository, extracting only the directory you want (with its full history).

See Detach subdirectory into separate Git repository

Note the git clone --no-hardlinks /XYZ /ABC used during the cloning step:

The --no-hardlinks switch makes git use real file copies instead of hardlinking when cloning a local repository.

这篇关于如何从现有git存储库中的文件夹创建新的git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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