如何提取位于外部 git 存储库的特定文件夹中的所有项目

How to pull all items within a specifc folder located on external git repository

我正在尝试提取我的 git 存储库中特定文件夹中的所有文件和文件夹。我已经尝试过使用 sparce-checkout 但这会拉出特定的文件夹。我希望它只提取文件夹中的文件。

我有一个名为 /EWINS/ 的文件夹,我希望提取该目录中的所有文件夹和文件。

我试过:

git init

git config core.sparseCheckout true

git remote add -f origin https://MYDIRECTORY

echo "EWINS/*" >> .git/info/sparse-checkout

git pull origin master

然而,这会导致文件夹 EWINS 被拉到我需要 EWINS 中所有项目的位置。具体来说,我不想要 EWINS 文件夹,只想要其中的所有项目。

理论上我可以指定我想要的每个文件,这将起作用,但每次添加需要管理的新项目时我都必须编辑脚本,这是不合适的。

我参考了:

How do I clone a subdirectory only of a Git repository?

http://lakehanne.github.io/git-sparse-checkout

如有任何帮助,我们将不胜感激。

示例:

我收到:

EWINS\app.test , text.txt, note.pad

我要:

app.test、text.txt、note.pad

A Git sparse checkout 仍然使用工作树来恢复其内容。这意味着您将始终获得 EWINS 文件夹。

我的解决方法是在专用文件夹中执行此检出,然后使用正确的文件夹创建一个 mirror-rsync(该文件夹位于 Git 存储库之外,不受 Git)。