0

I am absolutly new in GIT and I have some problem to understand how read the graph of a project on which I am working on.

So I do the following operation.

1) I create a new local branch named easy-mode on my project, in this way:

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids (master)
$ git branch easy-mode

2) Then I see all the brances of my project (local and remotes) by:

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids (master)
$ git branch -a
  easy-mode
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/coins
  remotes/origin/master

So I have the active local branch that is master, the easy-mode empty branch and 3 remote branches.

3) I switch from the master branch to the easy-mode branch so every new commit will be done on the easy-mode branch and not on the master, by:

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids (master)
$ git checkout easy-mode
Switched to branch 'easy-mode'

Infact now it is switched:

$ git branch
* easy-mode
  master

4) I modify a file named game.js into my project and I add and commit it so it will be commited into the easy-mode branch.

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids (easy-mod
e)
$ git add game.js

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids (easy-mod
e)
$ git commit
[easy-mode e06528a] feature: easy mode: the asteroids will be splitted in 2 inst
ead 3.
 1 file changed, 2 insertions(+)

5) Now I print the graph by git log --graph --oneline --decorate=full --all:

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids (easy-mod
e)
$ git log --graph --oneline --decorate=full --all
* e06528a (HEAD -> refs/heads/easy-mode) feature: easy mode: the asteroids will
be splitted in 2 instead 3.
* cba1887 (refs/heads/master) fixing: fixed the bug related of the weapon delay
* 3884eab (refs/remotes/origin/master, refs/remotes/origin/HEAD) Add color
* 3e42136 now using requestAnimationFrame
* 4035769 frame interval was set wrong after game was paused
* 25ede83 a couple missing ends with the ipad version
* df03538 I can't spell 'screen' apparently :)
| * 354dfdd (refs/remotes/origin/coins) Make ships able to spawn on coins
| * 0c6daf1 Make it possible to collect coins
| * a3c0ae4 Create helper functions
| * 656b02e First pass at adding coins
|/
* b0678b1 Revert controls

................................................................
................................................................
................................................................

And here I have some problem to understand how have I to read the previous graph.

Why the remote branch refs/remotes/origin/coins is identified by something like a "subtree" that start with the |/ characters:

| * 354dfdd (refs/remotes/origin/coins) Make ships able to spawn on coins
| * 0c6daf1 Make it possible to collect coins
| * a3c0ae4 Create helper functions
| * 656b02e First pass at adding coins
|/

and the refs/heads/easy-mode branch seems more like a node into the graph and not as a subtree?

Another doubt is related to the fact that this easy-node branch is idenfied by (HEAD -> refs/heads/easy-mode). Why HEAD? It seems to me that this branch is the head of the project (that contains the last commit or something like this) but a branch should not be as a new separated branch in the tree?

What is wrong in my consideration? What am I missing?

AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • 1
    The name Git, like Perl, is not an acronym for anything in particular and should not be written in capital letters. – trent Jul 28 '16 at 15:48

1 Answers1

2

The git log shows commits formatted for time not the branch structure.

If you colourize the git log then you may be able to see that the master is not always the leftmost branch.

git log log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all

from Pretty git branch graphs

git log graph
from Viewing full version tree in git

Community
  • 1
  • 1
Borian
  • 622
  • 10
  • 19