大约一个月前,我克隆了一个远程git存储库。远程存储库经历了许多更改,现在变得不稳定了。现在我需要存储库的另一个副本,与我一个月前克隆的版本相同。
我怎么做呢?
大约一个月前,我克隆了一个远程git存储库。远程存储库经历了许多更改,现在变得不稳定了。现在我需要存储库的另一个副本,与我一个月前克隆的版本相同。
我怎么做呢?
当前回答
与集中式版本控制系统不同,Git克隆整个存储库,因此您不仅可以获得当前的远程文件,还可以获得整个历史。您的本地存储库将包括所有这些。
There might have been tags to mark a particular version at the time. If not, you can create them yourself locally. A good way to do this is to use git log or perhaps more visually with tools like gitk (perhaps gitk --all to see all the branches and tags). If you can spot the commits hashes that were used at the time, you can tag them using git tag <hash> and then check those out in new working copies (for example git checkout -b new_branch_name tag_name or directly with the hash instead of the tag name).
其他回答
你可以这样求解:
git reset --hard sha
例如:85a108ec5d8443626c690a84bc7901195d19c446
您可以通过以下命令获取所需的sha:
git log
与集中式版本控制系统不同,Git克隆整个存储库,因此您不仅可以获得当前的远程文件,还可以获得整个历史。您的本地存储库将包括所有这些。
There might have been tags to mark a particular version at the time. If not, you can create them yourself locally. A good way to do this is to use git log or perhaps more visually with tools like gitk (perhaps gitk --all to see all the branches and tags). If you can spot the commits hashes that were used at the time, you can tag them using git tag <hash> and then check those out in new working copies (for example git checkout -b new_branch_name tag_name or directly with the hash instead of the tag name).
你需要的源树在git存储库中仍然可用,但是,你将需要你感兴趣的提交的SHA1。我假设你可以从当前的克隆你有SHA1 ?
如果您可以获得这个SHA1,那么您可以在那里创建一个分支/重置以拥有相同的存储库。
命令按照睿的回答
也许git重置可以解决你的问题。
git reset --hard -#commit hash-
你可以简单地使用
git checkout commithash
在这个序列中
git clone `URLTORepository`
cd `into your cloned folder`
git checkout commithash
提交哈希看起来像这样“45ef55ac20ce2389c9180658fdba35f4a663d204”