Temporarily switch working copy to a specific Git commit

前端 未结 3 1978
慢半拍i
慢半拍i 2020-12-22 14:58

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 w

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 15:23

    First, use git log to see the log, pick the commit you want, note down the sha1 hash that is used to identify the commit. Next, run git checkout hash. After you are done, git checkout original_branch. This has the advantage of not moving the HEAD, it simply switches the working copy to a specific commit.

提交回复
热议问题