use*_*912 33 git sparse-checkout
我有一个包含子目录的git存储库.示例dirA/dirB.有没有办法git clone
在Unix服务器上只从子目录(dirB)中提取文件?
除了克隆之外还有其他一些git命令可以执行此操作吗?
我如何git特定文件?
unu*_*tbu 30
假设您的项目位于一个被调用的目录中project
,并且您只想要那些触摸的提交project/dirB
.
然后:
git clone project/ subproject/
cd subproject
git filter-branch --prune-empty --subdirectory-filter dirB HEAD
Run Code Online (Sandbox Code Playgroud)
subproject
现在将包含触及的git历史记录dirB
.
Bru*_*mas 18
Cf https://www.kernel.org/pub/software/scm/git/docs/git-archive.html
使用shell命令:
git archive --remote=<repo_url> <branch> <path> | tar xvf -
Run Code Online (Sandbox Code Playgroud)
Ben*_*ine -1
如果您只想克隆存储库的一部分,您应该查看git submodules。
子目录由特定的 git 存储库管理,并在主存储库中作为子模块引用。
当您克隆主存储库时,子模块不会自动克隆。