git --all missing commit

后端 未结 3 1843
闹比i
闹比i 2021-01-06 17:00

Can someone please help me understand what\'s happening here?

I start with git log --oneline, which spits out:

4df9421 (HEAD, master) mo         


        
相关标签:
3条回答
  • 2021-01-06 17:07

    You should accept VonC's answer. To complete it :

    The "missing commit" was not pushed to the server, or saved in another branch. Your git reset --hard thus deleted it.

    Fortunately, git has some sort of magic undo stack : git reflog. Check VonC's link to figure out how to get it back.

    Be careful when you use git reset, this command can destroy commits.

    As a rule of thumb : before you manipulate your history, make sure you still have some way of getting back to where you were. My local repositories are crippled with backup, orig and wip branches, which I clean up every month or so.

    0 讨论(0)
  • 2021-01-06 17:21

    The --all option does not tell git log to display all commits. It asks for the logs of all refs, basically your branches and tags. The reset command removed that commit from master, the only ref that had included it so that commit is now unreachable.

    0 讨论(0)
  • 2021-01-06 17:27

    It is missing, because it isn't reference anymore by HEAD or by a branch.
    You have reset both (HEAD and master) to another commit, with your git reset --hard.

    Only git reflog would show you that recent commit.

    git log --all is only for listing commits referenced in refs/ (like tags, heads, ...)

    --all
    

    Pretend as if all the refs in refs/ are listed on the command line as <commit>.

    0 讨论(0)
提交回复
热议问题