我们如何理解命令:"git checkout commit_id ."

How do we understand the command: "git checkout commit_id ."

我知道 git checkout commit_id 会将 head 移动到 commit_id 我会得到一个分离的头,我的工作 space 将被 commit_id.

今天我发现另一个 git checkoutgit checkout commit_id .。这个点给了我不同的东西。它似乎用 commit_id 覆盖了我的工作 space 和 git 的索引,而 head 没有移动。

我怎么理解这个命令?为什么点停止移动 head?

git 如果给定路径,检出可用于将文件恢复到特定版本。

在这种情况下,您要将整个当前目录恢复到它在 commit_id

时的版本

来自git documentation about checkout

When <paths> are given, this command does not switch branches. It updates the named paths in the working tree from the index file, or from a named <tree-ish> (most often a commit).