Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of parents and children of a commit in GIT

Tags:

git

Please correct me if I am wrong:

The number of parents of a commit can be:

  • 0 - only for the initial commit in the REPO
  • 1 - for a simple commit on some branch
  • 2 - for a merge commit

The number of parents cannot be more than 2.

The number of children can be any non-negative number.

  • Zero for commit on the tip of one or more branches
  • One for simple commit on a branch
  • Any value greater than one if several branches were created out of a commit and these branches have commits.
like image 643
Buran Avatar asked Sep 01 '25 11:09

Buran


1 Answers

The number of parents can be any non-negative number, see the octopus strat, and a 0-parent commit can be added at any time, though there's legitimate debate over that usage such debates tend to be settled in favor of usefulness.

like image 114
jthill Avatar answered Sep 03 '25 01:09

jthill