eDeviser
eDeviser

Reputation: 1873

How to interpret the brackets in the git log?

Running git log gives me an output like this:

commit 69b6309f09365c09a2fe10f09aee801d1fae29ee (HEAD -> master, edeviserBranch)
Author: eDeviser <[email protected]>
Date:   Mon Sep 2 09:53:07 2019 +0200

    added foo

commit 59a08270fb730db259a8d5819bb585a613024d97 (origin/master, origin/HEAD)
Author: eDeviser <[email protected]>
Date:   Mon Sep 2 09:49:50 2019 +0200

    More Text

I don't understand the meaning of the content inside the brackets. What is the meaning of the text inside the brackets? Is this the branch which is the commit based on? If yes, what is the difference between HEAD -> master, origin/master and origin/HEAD?

How to interpret the brackets in the git log?

Upvotes: 9

Views: 3584

Answers (3)

mfnx
mfnx

Reputation: 3018

Short answer

It is a list of pointers which are pointing to the corresponding commit. I recommend you read about HEAD and origin.

Commits and pointers

In git, you have commits and pointers moving in between those commits. A branch is just a pointer which points to a commit. Say you have a branch mybranch, then mybranch is just a pointer. If you commit on that branch, the pointer mybranch just moves on to that commit.

The HEAD pointer

HEAD: the HEAD pointer points to the current commit your repo is on. In your case, it is pointing to commit 69b6309f09365c09a2fe10f09aee801d1fae29ee, that is: your repo is now on commit 69b6309f09365c09a2fe10f09aee801d1fae29ee. The content in parenthesis is a list of other pointers which point to the same commit as HEAD, which, in your case are master and edeviserBranch. From that information, you can see that master and edeviserBranch have not diverged yet. You probably pushed the last commit with text added foo onto master and then created a new branch edeviserBranch from master.

The working area

origin: the default name that git gives to your remote repo. With origin/<pointer>, you can access branches in your working area. The working area is a space between your local and remote repositories. git fetch origin downloads the data from your remote repo to the working area of your local repo. It doesn't merge any data, it just downloads it. An example to make the concept of working area clear:

git fetch origin # update data from remote origin.
# For example, your remote branch edeviserBranch will be downloaded to your working area
# and can be accessed from origin/edeviserBranch.

git checkout master # go to your local master branch
git merge origin/edeviserBranch # merge branch edeviserBranch from your working area
# to your local master branch

The origin/HEAD pointer

origin/HEAD: a pointer in your working area which points to the default commit that will be checked out by someone cloning your repository.

According to the output of git log, pointer origin/master and origin/HEAD both point to commit 59a08270fb730db259a8d5819bb585a613024d97.

If your working area is not synchronized with your remote repo, and you execute git fetch origin (and doing so, you update your working area with your remote repo), those pointers will change.

Upvotes: 11

Energya
Energya

Reputation: 2673

They indicate at which commits the various branch pointers in your repository are currently.

HEAD -> master means that this is the HEAD, i.e. current working directory, which happens to belong to the master branch.

edeviserBranch shows that your current local branch edeviserBranch is also pointed at that same commit.

origin/master at your previous commit means that the remote of your branch master is still at that previous commit, i.e. your remote master is one commit behind your local repository.

origin/HEAD is the default branch/commit that will be checked out by someone cloning your repository anew (source)

Upvotes: 4

su3158
su3158

Reputation: 613

HEAD remembers the branch location HEAD-> master is where you work

The latest commit of the current branch If you move (check out) a branch, the HEAD position will change

The location of the remote repository where you are remotes / origin / HEAD-> origin / master // HEAD location

Upvotes: 1

Related Questions