Question

Trying to understand git in a bit more detail. In the graph output of git log, what do the lines and dots mean? Why are the dots only on the left for part of it, and only on the right for another part? Is it because I ran the command from a specific branch? Would it be different form master? Is a pull merge shown differently?

enter image description here

Was it helpful?

Solution 2

The asterisks denote commits and the lines parent child relations.

So basically it means that you have two branches (let's call them left and right). That you worked a lot on the left one, next on the right one, you merged the right in the left, worked further on the right one and merged again.

In case you do a merge they use some ASCII art to denote that the right one is still active. That's one of the reasons I prefer tig who has a cleaner syntax.

OTHER TIPS

This is important to know, especially on stackoverflow, since many questions and answers will take the form of representative graphs like the ones I have below.

Each asterisk is a commit, the lines lead downward to each parents commit. A commit is also a parent commit, if it is immediately below another commit.

* D (master)
* C
* B
* A

In the above example, A is the first commit, and B is the second, so on - the ancestry is D->C->B->A. This part is obvious but lets say you make a branch based on B and add a new commit.

* D (master)
* C
| * E (dev)
|/
* B
* A

So now we have two branches, master, and dev. The ancestors for D (master) are D->C->B->A while the ancestry for E (dev) is E->B->A.

Where you see two lines split apart, that means the two commits those lines lead to both consider that common commit a parent - in the case above B is a parent to both E and C.

Lets say you then go ahead and add another commit to the dev branch, and then decide you are ready to merge dev into master.

* G (master)
|\
* | D 
* | C
| * F (dev)
| * E
|/
* B
* A

The diagram above shows that you added the F commit right after E (see how the asterisks are directly above/below one another). You then afterward checked out the master branch and merged in dev. This created a merge commit, and here its called G.

Above I explained how lines splitting away from the same commit upward mean that where those lines lead, the two commits consider the first their common parent. In this case however, G has two lines leading into it. This means that it has two parents. It is a merge commit.

In the at last diagram you'll notice the commits (asterisks) are on different lines.

* | D (master)
* | C
| * F (dev)
| * E

All these commits are merged together now, but D and C were created on a different branch than F and E. The side that the asterisk is on, denotes which branch the commit belongs to. D was made on the master branch and E was made on the dev branch.

These merged histories can get really entangled, they aren't always as neat and orderly as yours is right now. You may chose to care about how your history looks, and may decide to try to shape it by doing things like merging with --no-ff or --ff-only, or performing rebases. I won't get into that, except to say that these are ways people can control how the git history graph looks (which matters).

The stars are commits (at the right side), the lines connect commits (i.e., they show connections).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top