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).