The parent commit is the commit this current commit is based on. Usually:
- When you
git commitnormally, the current commit becomes the parent commit of the new commit that’s introduced by the command. - When you
git mergetwo commits (or branches, whatever) without fast-forwarding, a new commit will be created with both commits as parents. You can merge more than two commits in that way, so the new commit may have more than one parent.
Essentially, the commit tree (or DAG, if we want to be accurate) is made up of those parent<-child relationships, with the children (more “recent”[1] commits) point to the parents (less “recent”[1] commits).
The only exception is the initial commit (or any other root commits), which has no parents.
- “recent” isn’t exactly an accurate term, as you may have a very old branch on the one hand, and a very new one on the other. And a child commit may be a lot “older” than another commit which is a parent elsewhere.