6

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:

  • Column1 is obviously the commit,
  • Column2 is where I get confused. I understand the HEAD@{0} to HEAD@{7} concept. Don't get the parts that are in the parenthesis!. What does (yy, alphabets, hotFix) represent?
  • Column3 is the action i.e. checkout/pull along with a message.

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?

1
  • 1
    I also read from git-reflog's documentation, but from what I see it's either not mentioned or I'm not good with reading its manual. I just wish there was some documentation that would just tell you if you do this command, then these are the column labels. All I see in the help pages is each commands options Commented Feb 5, 2018 at 19:42

1 Answer 1

8

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 for git log -g --abbrev-commit --pretty=oneline;

784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master 
  1. 784f2cp3 The abbreviated commit.
  2. (yy, alphabets, hotFix) The branch heads at this commit, just like git log --decorate.
  3. HEAD@{7} The location of this commit relative to HEAD, added by -g.
  4. checkout What command was run.
  5. 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.

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks. What does HEAD -> master mean here?
@Honey It means master is currently checked out, HEAD points at master.
I just did another git reflog and got : (HEAD -> develop, origin/develop, origin/HEAD). What does origin/HEAD mean here? I understand the other two...
@Honey It's the position of HEAD on the remote repository called origin. See this answer for more.
Why do only some reflog entries have parentheses?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.