使用 Android Studio 从 GitHub 克隆存储库的子目录

Cloning a subdirectory of a repository off GitHub using Android Studio

我想知道是否可以使用 Android Studio 从 GitHub 克隆存储库的子目录?通常当你克隆一个存储库时,你会 "Check out project from Version Control" --> GitHub --> 然后你会得到这样的东西

但是,例如,我想克隆这个子存储库,因为我想构建项目并将其放入我的模拟器中。这个地址是 https://github.com/hmkcode/Android/tree/master/android-material-design-appcompat.

我曾尝试猜测 https://github.com/hmkcode/Android.git 可能已成为 https://github.com/hmkcode/Android/android-material-design-appcompat.git,但这并没有奏效。

是否可以克隆此子存储库,因为我不想要存储库的其余部分。我不想克隆整个项目并尝试拼凑子项目。

这不是 "subrepo":它只是一个子目录,并且 git 原因在回购级别。
你可以使用 sparse checkout though, but it is not supported directly by Android studio. You would have to prepare your local repo:

mkdir hacker-scripts
cd hacker-scripts
git init .
git config core.sparseCheckout true
echo 'android-material-design-appcompat/' > .git/info/sparse-checkout
git remote add -f origin https://...
git pull origin master