What exactly is a “grafted” commit in a shallow clone?

后端 未结 1 858
再見小時候
再見小時候 2021-02-02 06:23

When doing a shallow clone in git (using the --depth option), the root commit is marked as grafted.

1条回答
  •  一生所求
    2021-02-02 06:49

    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.

    0 讨论(0)
提交回复
热议问题