'Can a Git commit have multiple tree objects?
Does a commit object always have exactly one tree object?
I can't think of a scenario where it wouldn't be the case but I also can't see any documentation that explicitly states it.
Solution 1:[1]
Does a commit object always have exactly one [top-level] tree object?
Yes.
I can't think of a scenario where it wouldn't be the case but I also can't see any documentation that explicitly states it.
It's part of the design: without it, git rev-parse commit^{tree} would not have an unambiguous result.
One can envision a system related to Git in which commits can store multiple trees,1 but a number of design issues would need to be resolved first.
1I've thought about this in several contexts, including the "submodules are wrong, subtrees are better but need better support" one. I have not resolved everything. ?
Note that the commit object is also required to have exactly one author and one committer line; git fsck will object to the commit if these are malformed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
