Reputation: 208
Can someone please help me understand what's happening here?
I start with git log --oneline
, which spits out:
4df9421 (HEAD, master) moved some aliases around
d3810e4 (origin/master) some terminal color changes
a7182d3 git colors, ignores, etc.
995fe8c added gitconfig, moved some personal stuff out of the public repo
8a100b7 misc unimportant updates
55d2c08 added a fix to "open with", refactored
7ec7d83 Removed some vim colors; added a couple searching aliases
330c7fc Minor updates
44e80a1 Added vim files
48537c6 Fixed some formatting problems
14933a2 Initial Commit
then I do git reset --hard 330c7fc
which takes the log back to:
330c7fc (HEAD, master) Minor updates
44e80a1 Added vim files
48537c6 Fixed some formatting problems
14933a2 Initial Commit
So far so good, but (now that I've reset) when I do git log --oneline --all
I get:
d3810e4 (origin/master) some terminal color changes
a7182d3 git colors, ignores, etc.
995fe8c added gitconfig, moved some personal stuff out of the public repo
8a100b7 misc unimportant updates
55d2c08 added a fix to "open with", refactored
7ec7d83 Removed some vim colors; added a couple searching aliases
330c7fc (HEAD, master) Minor updates
44e80a1 Added vim files
48537c6 Fixed some formatting problems
14933a2 Initial Commit
Notice that the most recent entry, "4df9421 moved some aliases around", is missing from this list.
My understanding is that the --all
option should display all the commits. Why is the latest missing once I revert to an earlier commit?
Thanks.
Upvotes: 5
Views: 2378
Reputation: 51850
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.
Upvotes: 0
Reputation: 19475
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.
Upvotes: 2
Reputation: 1324218
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>
.
Upvotes: 6