日食伊吉特。结帐创建新的提交。为什么?

Eclipse Egit. Checkout creates new commit. Why?

据我了解GIT,当我在提交时签出时,我应该将其文件复制到我的工作目录中,但不会出现新的提交。尽管 当我使用 EGit 并在提交时签出时,我在 reflog 中看到了新的提交。为什么? 据我了解结帐不应创建新的提交。对吗?

这里我右击commit然后选择checkout

然后我在 reflog 中得到新的提交:

所以现在我在本地 master 中的提交很少,但我从来没有要求这样做。

Git Eclipse 集成 - 以任务为中心的界面 4.6.1.201703071140-r org.eclipse.egit.mylyn.feature.group Eclipse EGit

您在 reflog 中没有看到新的提交。您看到的是 HEAD 的更新位置。您在签出时将其更改为提交 4b0d96a。当您签出另一个提交、分支或标记时,您会看到另一个条目出现在 reflog 中。

尝试在两个分支之间反复切换,您会看到相同的两个提交哈希一次又一次地附加到 reflog。这并不意味着您正在创建新的提交。您只会看到现有提交被记录为 HEAD 指针指向的最近提交。

来自git reflog docs

This command manages the information recorded in the reflogs.

The "show" subcommand (which is also the default, in the absence of any subcommands) shows the log of the reference provided in the command-line (or HEAD, by default). The reflog covers all recent actions, and in addition the HEAD reflog records branch switching. git reflog show is an alias for git log -g --abbrev-commit --pretty=oneline; see git-log for more information.

您可能也会觉得这个 chapter of the Pro Git book 很有趣。它对 git reflog 的作用提供了更易于理解的描述。

您必须使用 History 视图而不是 Git Reflog 视图(详见git reflog and ):

  1. 告诉历史视图应该显示哪些历史:e。 G。 Git 存储库 查看右键单击 存储库并选择:显示在 > 历史记录.
  2. 历史视图中启用选项显示所有分支和标签(右键在视图工具栏中)。否则,只显示当前分支的提交。