I just did a simple git reflog
and this is the first few lines I got:
column1 Column2 Column3
2797a1d4 (HEAD -> master, upstream/master) HEAD@{0}: checkout: moving from master to master
2797a1d4 (HEAD -> master, upstream/master) HEAD@{1}: pull upstream master: Fast-forward
a461a29f HEAD@{2}: checkout: moving from master to master
a461a29f HEAD@{3}: reset: moving to HEAD
a461a29f HEAD@{4}: pull upstream master: Fast-forward
784f2cp3 (yy, alphabets, hotFix) HEAD@{5}: checkout: moving from yy to master
784f2cp3 (yy, alphabets, hotFix) HEAD@{6}: checkout: moving from master to yy
784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
I'm trying to understand what each column represents. Reading from this post and this question I've already learned:
HEAD@{0}
to HEAD@{7}
concept. Don't get the parts that are in the parenthesis!. What does (yy, alphabets, hotFix)
represent?Additionally I'm uncertain as to why there is multiple lines of the same commit? Is it because different branches are all pointing to the same commit and there is no code changes between them?
Reflog is a mechanism to record when the tip of branches are updated. This command is to manage the information recorded in it. Basically every action you perform inside of Git where data is stored, you can find it inside of the reflog.
git reflog directories can be found at . git/logs/refs/heads/. , . git/logs/HEAD , and also . git/logs/refs/stash if the git stash has been used on the repo.
a reflog is a very special “branch” that records each position of HEAD in the last 30 days (by default). So removed branches won't be purged by prune until after waiting for 30 days, when the last reference to them will finally be released. reflog history is not shared – it is exclusive to your repository.
The biggest difference between Git reflog vs. log is that the log is a public accounting of the repository's commit history while the reflog is a private, workspace-specific accounting of the repo's local commits. The Git log is part of the Git repository and is replicated after a push, fetch or pull.
The reflog tells you how HEAD
has moved. There are more than three columns. The Git docs are obtuse about this. It turns out git reflog
is just an alias for git log
with some switches.
git reflog show
[the default] is an alias forgit log -g --abbrev-commit --pretty=oneline;
784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
784f2cp3
The abbreviated commit.(yy, alphabets, hotFix)
The branch heads at this commit, just like git log --decorate
.HEAD@{7}
The location of this commit relative to HEAD
, added by -g
.checkout
What command was run.moving from alphabets to master
A human readable description.(4 and 5 are technically the same column.)
This says you were on branch alphabets
and ran git checkout master
.
Additionally I'm uncertain as to why there is multiple lines of the same commit? Is it because different branches are all pointing to the same commit and there is no code changes between them?
Yes, exactly.
784f2cp3 (yy, alphabets, hotFix) HEAD@{5}: checkout: moving from yy to master
784f2cp3 (yy, alphabets, hotFix) HEAD@{6}: checkout: moving from master to yy
784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
yy
, alphabets
, hotFix
, and master
were all on the same commit. Checking out between them simply changes which branch head will be moved the next commit.
The others might be internal HEAD
movements which happen when you run git pull
. git pull
is a combination of git fetch
and git merge
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With