How do I obtain a single revision from a git repository without cloning the whole repository ?
Note : this question has been asked 100s of times but I have yet to see an answer that solves it since they all start with "clone the whole git repository". This cannot be done in my use case.
The best I can do is:
depth
of the commit. git clone --depth $depth $git_repo_url
. git checkout $commit_hash; git reset --hard
git checkout $commit_hash; git reset --hard
. But this still requires cloning up to the commits depth.
Is there a way to avoid that and clone only a particular commit with depth 1?
Not with clone
but with pull
/ fetch
. See this post:
How to clone git repository with specific revision/changeset?
Retrieve specific commit from a remote Git repository
git init git fetch --depth 1 url://to/source/repository <sha1-of-commit>
And set uploadpack.allowReachableSHA1InWant
on the server side.
如果您进行reflog和git cherry-pick怎么样
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.