使用git checkout命令切换到指定的commit

git checkout命令有很多种用法。

  1. git checkout + 分支名,切换到指定的分支。

比如git checkout develop:

切换之后,HEAD文件的内容:

ref: refs/heads/develop

  1. git checkout + 文件夹

丢弃工作区域中指定文件夹下面的修改:

  1. git checkout + commit id

切换到指定的commit上去。

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

HEAD is now at 7bda819fd fix: organization library should compile without core style library (#9637)

现在HEAD文件的内容:
7bda819fdf88bd171f63bcc155b8002b6d2a2a8e

更多Jerry的原创文章,尽在:"汪子熙":


你可能感兴趣的:(使用git checkout命令切换到指定的commit)