暂时将工作副本切换到特定的Git提交

问题描述:

如何切换到特定的Git提交而不会丢失所有提交的提交

How to switch to specific Git commit without losing all the commits made after it?

我希望本地文件将被更改,但提交'数据库将保持不变,只有当前位置指针设置为当前选定的提交。

I want that local files will be changed, but commits' database will remain intact, only the current position pointer is set to currently selected commit.

我想将文件的状态更改为特定的提交,运行项目,完成后,恢复文件返回上次提交。

I want to change files' state to specific commit, run project and, when finished, restore files back to last commit.

如何在不压缩整个项目文件夹的情况下执行此操作?

How to do this without zipping the whole project's folder?

如果您位于某个分支 mybranch ,请继续前进, git checkout commit_hash 。然后你可以通过 git checkout mybranch 返回你的分支。我今天有同样的游戏平分错误:)另外,你应该知道 git bisect

If you are at a certain branch mybranch, just go ahead and git checkout commit_hash. Then you can return to your branch by git checkout mybranch. I had the same game bisecting a bug today :) Also, you should know about git bisect.