Home > Software engineering >  Number of parents and children of a commit in GIT
Number of parents and children of a commit in GIT

Time:05-30

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.

CodePudding user response:

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.

  •  Tags:  
  • git
  • Related