Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my git log output show both origin and origin/master, origin/HEAD when using a remote. These entries seem redundant to me

Tags:

git

git-branch

I am going through git branching concepts from 3.1 Git Branching - Branches in a Nutshell

I am playing with dummy repository.

git log --oneline --decorate gives following output.

$ git log --oneline --decorate
d0006a6 (HEAD, origin, tag: Test1, origin/master, origin/HEAD, master) Minor change 
1437545 Minor change
69a948a Added Makefile
617ffeb Spell correction
6bf9b3f First commit
$ git branch 
* master
$ git remote --v
origin  /home/adil/work/git/repo/ (fetch)
origin  /home/adil/work/git/repo/ (push)

I am not clear with multiple entries with origin and master. Like origin, origin/master, origin/HEAD, master

The sample output in the URL gives:

f30ab (HEAD, master, testing) add feature #32 - ability to add new

Similarly I was expecting the output to be:

d0006a6 (HEAD, tag: Test1, master) Minor change

One thing could be difference point is, in our case, its having remote. So I think that's why origin is coming but why origin, origin/master, origin/HEAD 3 extra entries?

like image 641
Adil Avatar asked Oct 25 '25 06:10

Adil


1 Answers

This is something fundamental you have to understand about git.

  • origin is your remote. It can be named anything else, but the main remote is named origin by convention

  • origin/master is your main or master branch in the remote named origin. Again the name master is simply convention and it can be anything else.

  • origin/HEAD is wherever your git is pointing to currently. If you have multiple branches like master and develop, you can checkout to develop. Effectively that action will point HEAD to develop. It is possible to use HEAD like any other branch in git commands. It is just a pointer to what branch you are on currently.

EDIT

Maybe I misunderstood the question, so some more explanation

The three of them are shown so that you know the status of the three things I have explained above.

  • origin/HEAD at a commit tells you the default branch of origin is pointing to that commit
  • master tells you that your local repo is at that particular commit
  • origin/master tells you that these changes have been pushed to remote and the master branch in your remote is up to date with your local repo

If you had not pushed your changes to remote repo, the origin/HEAD and origin/master would be at the commit that was last pushed to the remote

like image 133
TheGeorgeous Avatar answered Oct 26 '25 23:10

TheGeorgeous