有没有任何方法可以从远程Gitrepo中只检索一个特定的提交,而无需在PC上克隆它?
发布于 2018-01-11 13:34:26
Git可以将所有东西存储在.git
文件夹。但提交不能单独获取和存储
可以要求git只获取与特定分支或提交相关的对象:
git fetch origin refs/heads/branch:refs/remotes/origin/branch
也可以指定SHA 1提交:
git fetch origin 96de5297df870:refs/remotes/origin/foo-commit
发布于 2018-01-11 14:58:12
使用Git 2.5+,获取一次提交实际上是可能的!
uploadpack.allowReachableSHA1InWant
允许
upload-pack
若要接受请求从任何推荐提示中访问对象的获取请求
与浅层克隆的组合(git fetch --depth=1
)
git fetch --depth=1 ../testrepo/.git $SHA1
git cat-file commit $SHA
https://stackoverflow.com/questions/-100001341
复制相似问题