我已经提交了一个文件,提交 ID(哈希值)是 1234。 在同一个文件中,我做了很多更改,并再次提交了一个文件,因此新的哈希值是 567。 我重复这个过程,所以新生成的哈希值就像 8910,111213。
我想返回版本 1234(与我第一次 checkin 时获得的版本相同)
具体步骤是什么?
最佳答案
您可以 checkout 提交哈希,然后根据需要从中创建分支。您将在历史记录的那个时刻与树进行交互。
如果你运行git checkout <hash>
您将把树更新到历史记录中的该点。根据您使用的 git 客户端,您会收到类似的消息
> git checkout <hash>
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
关于git - 如何在 git 中的特定哈希(提交)处 checkout 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61183772/