what does reachable/unreachable mean in git?

后端 未结 2 1733
猫巷女王i
猫巷女王i 2021-01-04 04:40

Little bit confused..

In the git community manual, it says

The git log command can show lists of commits. On its own, it shows all commit

相关标签:
2条回答
  • 2021-01-04 05:03

    in Git, every commit you make (except for the very first) will have a parent commit. It follows that any given commit (except the first) is a child of one (or possibly more than one) other commit. You can also have several branches of development in Git, that begin or deviate at a particular ancestral commit. Nothing in Git dictates that commits must occur in either a chronological or linear order, and thus the git log tool needs to be able to deal with several ways of querying history.

    For instance, assume I develop my application and make commits in alphabetical order:

    ---A---B---E---G
        \       \
         C---D   F
    

    In this example, I must have made a new branch on commit A and E.

    If I were to run git log <D> (where <D> is the commit's SHA), then the log history would look like this:

    D---C---A---
    

    From that commit, only the parents and their ancestor commits can be 'seen'. Commits B, E, F and G are technically 'unreachable' from commit D, as they share no common connected parent commit.

    0 讨论(0)
  • 2021-01-04 05:25

    "Y is reachable from X" means object Y is reachable from the DAG. Depends on what Y is, this can means:

    • Y is a commit: Y is a parent/ancestor of X.
    • Y is a directory/folder/blob: Y is a part of (to say) a commit in the parent/ancestor tree of X.

    For some doc (e.g. git-fsck), it just say "Y is reachable". This means Y is reachable from some tag/branch (i.e. Y cannot be garbage collected)

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