![](/img/trans.png)
[英]Clone GIT Repository Subfolder into existing Repo with identical folder structure
[英]Clone specific folder from git repository without the subfolder structure
假设我有一个具有以下结构的存储库:
A/B/file1
A/B/file2
A/C/file3
D/E/file4
D/F/file5
我想在本地文件夹my / local / folder中检出A / B /的内容,但我不希望使用稀疏检出得到的子目录结构。
最终结果不应为:
my/local/folder/A/B/file1
my/local/folder/A/B/file2
但
my/local/folder/file1
my/local/folder/file2
如何使用GIT做到这一点?
如果您希望仅使用选定文件来清理工作目录,则必须从零开始。
首先,您需要克隆存储库,避免检出任何文件。 您可以使用clone
命令的-n
参数完成此操作:
git clone -n path/to/repo.git
然后,您可以通过运行以下命令来选择要检出的特定文件:
git checkout HEAD:path/to/file filename
或者您只需通过将文件名更改为*
来签出提供的文件夹中的所有文件:
git checkout HEAD:path/to/file *
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.