是否可以浅层克隆存储库中的特定提交,即深度为1? 就像是
git clone http://myrepo.git 728a4d --depth 1
在提交SHA 728a4d
时获取存储库状态...?
其动机是避免必须克隆整个存储库,然后检查特定的提交,当我们只关心该特定提交的存储库状态时。
发布于 2018-03-12 15:31:18
从Git 2.5.0开始(需要在双双(客户机和服务器端)可以设置uploadpack.allowReachableSHA1InWant=true
在服务器端启用特定SHA 1的获取:
git init
git remote add origin <url>
git fetch --depth 1 origin <sha1>
git checkout FETCH_HEAD
发布于 2018-03-12 15:58:32
直接的答案是:你不能。
# Create empty repository to store your content
git clone <url>
git reset <sha-1> --hard
更多信息:
git clone <url> --branch <branch_name> --single-branch <folder_name>
git clone <url> --depth=1 --branch <branch_name> --single-branch <folder_name>
--depth
暗示--single-branch
...
使用FETCH命令代替克隆:
# fetch a commit (or branch or tag) of interest
# In this case you will have the full history of this commit
git fetch origin <sha1>
发布于 2018-03-12 17:32:12
试着使用while
在bash:
git clone --depth=1 $url
i=1; while ! git show $sha1; do git fetch --depth=$((i+=1)); done
https://stackoverflow.com/questions/-100003603
复制相似问题