Eclipse Egit. Checkout creates new commit. Why?

前端 未结 2 1677
野趣味
野趣味 2021-01-28 21:46

As I understand GIT, when I checkout on commit, I should get its files copy in my work directory, but no new commit should appear. Though when I use EGit and checkout on

相关标签:
2条回答
  • 2021-01-28 22:07

    You don't see a new commit in the reflog. What you see is an updated position of HEAD. You changed it to commit 4b0d96a when you checked it out. When you check out another commit, branch or a tag, you'll see yet another entry appear in the reflog.

    Try switching between two branches repeatedly and you'll see the same two commit hashes appended to the reflog again and again. This does not mean you're creating new commits. You just see existing commits being logged as recent commits pointed to by the HEAD pointer.

    From the 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.

    You may also find this chapter of the Pro Git book interesting. It offers a more comprehensible description of what git reflog does.

    0 讨论(0)
  • 2021-01-28 22:22

    You have to work with the History view instead of with the Git Reflog view (see git reflog and toniedzwiedz's answer for details):

    1. Tell the History view which history should be shown: e. g. in Git Repositories view right-click a repository and choose: Show In > History.
    2. In the History view enable the option Show All Branches and Tags (right button in the view toolbar). Otherwise, only commits of the current branch are displayed.
    0 讨论(0)
提交回复
热议问题