When doing a shallow clone in git (using the --depth
option), the root commit is marked as grafted.
Googling didn't lead to any satisfacting documentation.
It doesn't seem to have anything to do with git grafts, which the similar terminology would imply.
Is it just a flag to signal that this commit actually has more parents and isn't the "real" root commit? Or is there something more special about it?
Graft points or grafts enable two otherwise different lines of development to be joined together. It works by letting users record fake ancestry information for commits. This way you can make git pretend the set of parents a commit has is different from what was recorded when the commit was created. As of Git 1.6.
A shallow clone is a repository created by limiting the depth of the history that is cloned from an original repository. The depth of the cloned repository, which is selected when the cloning operation is performed, is defined as the number of total commits that the linear history of the repository will contain.
Git shallow clone can save time while cloning large repositories. However, if you push commit from a shallow clone it can take more time due to the difference calculations to be done between remote and shallow copies of your repository. So it is advisable to start with a shallow clone but eventually do a full clone.
From your link:
It works by letting users record fake ancestry information for commits. This way you can make git pretend the set of parents a commit has is different from what was recorded when the commit was created.
In a shallow clone, your root commit is one that should have parents, but not in your repo. So it seems a good use case for grafting.
In effect:
Def.: Shallow commits do have parents, but not in the shallow repo, and therefore grafts are introduced pretending that these commits have no parents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With