提取 Git 存储库中子文件夹中的所有文件

Pulling all files within a subfolder in Git repository

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

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

我试过:

git 初始化

git 配置 core.sparseCheckout 真

git 远程添加-f origin https://MYDIRECTORY

回显 "EWINS/*" >> .git/info/sparse-checkout

git拉源主

然而,这会导致文件夹 EWINS 被拉到我需要 EWINS 中所有项目的位置。

我参考了: How do I clone a subdirectory only of a Git repository?

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

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

正如之前 stack-overflow-er 的回答

这称为 sparse checkout,从 1.7.0 版本开始可用。

"Sparse checkout" allows populating the working directory sparsely. It uses the skip-worktree bit (see git-update-index) to tell Git whether a file in the working directory is worth looking at.

While $GIT_DIR/info/sparse-checkout is usually used to specify what files are in, you can also specify what files are not in, using negate patterns. For example, to remove the file unwanted:

/*
!unwanted

详情见linked answer and manual