Git:回滚到更早的版本

Git:回滚到更早的版本,git,Git,在整个回购过程中,有没有办法回滚到git中签入内容的更早版本?我不想更改回购协议中的内容,我只想要9个月前回购协议所在地的本地副本。是的,只需克隆回购协议 git clone <repo-url> …然后签出旧版本 git checkout <commit-sha1, branch, tag> 请记住,如果您签出提交,您将处于分离头模式。如果希望进一步提交,可以创建该提交的分支。是的,只需克隆该报告 git clone <repo-url> …然后签出旧

在整个回购过程中,有没有办法回滚到git中签入内容的更早版本?我不想更改回购协议中的内容,我只想要9个月前回购协议所在地的本地副本。

是的,只需克隆回购协议

git clone <repo-url>
…然后签出旧版本

git checkout <commit-sha1, branch, tag>

请记住,如果您签出提交,您将处于分离头模式。如果希望进一步提交,可以创建该提交的分支。

是的,只需克隆该报告

git clone <repo-url>
…然后签出旧版本

git checkout <commit-sha1, branch, tag>

请记住,如果您签出提交,您将处于分离头模式。如果您希望进一步提交,您可以创建一个提交分支。

您可以直接告诉git在9个月前签出一个分支。下面是我的一个项目中的一个示例:

:; git checkout 'master@{9 months ago}'
Checking out files: 100% (625/625), done.
Note: checking out 'master@{9 months ago}'.

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

HEAD is now at b50869f... ignore DerivedData

所有指定修订的方法都记录在中。

您可以直接告诉git在9个月前签出一个分支。下面是我的一个项目中的一个示例:

:; git checkout 'master@{9 months ago}'
Checking out files: 100% (625/625), done.
Note: checking out 'master@{9 months ago}'.

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

HEAD is now at b50869f... ignore DerivedData

所有指定修订的方法都记录在中。

非常感谢您的帮助。此git回购没有分支机构。只是有很多承诺。。。当我执行:git签出时,我收到一个错误:签出将删除以下未跟踪的工作树文件:有办法解决此问题吗?@Sparky1您可以将更改隐藏、提交到分支或删除它们。这是一个新的克隆。自从我克隆以来,我没有做任何改变。你的意思是我需要隐藏我想要回滚到的提交后9个月内发生的所有提交吗?@Sparky1不。我也不太熟悉你看到的消息。它成功了!我不得不做另一个新的克隆人,并尝试第二次,但它的工作!非常感谢你的帮助。此git回购没有分支机构。只是有很多承诺。。。当我执行:git签出时,我收到一个错误:签出将删除以下未跟踪的工作树文件:有办法解决此问题吗?@Sparky1您可以将更改隐藏、提交到分支或删除它们。这是一个新的克隆。自从我克隆以来,我没有做任何改变。你的意思是我需要隐藏我想要回滚到的提交后9个月内发生的所有提交吗?@Sparky1不。我也不太熟悉你看到的消息。它成功了!我不得不做另一个新的克隆人,并尝试第二次,但它的工作!非常感谢你的帮助。