Efficient way to find out which branches and/or commits point to an object?

Given a git object, is there a way to traverse upwards to find all commits and/or branches which point to it, or are they only linked in one direction? E.g.:

BLOB1 ----
          \
BLOB2 ----- C1 ---- C2 ---- B1
      \
       ---- C3 ---- B2

Starting from B1, can I traverse down to BLOB2, and then traverse back up to locate B2 (and any other branches which point to the same blob)? Or do I have to inspect all branches?

  • Merge back deleted file from a branch to master
  • List all merged branches except the current one?
  • Fail to checkout files from another local branch
  • How to revert multiple commits as part of a single commit
  • How to merge specific revision of my branch to other branch GitHUB?
  • gitignore - Ignore all file types except specified ones
  • Uncommited changes persist in checkout, generate no warnings
  • How do I list everyone who has ever committed to a file in Git?
  • How to create new git branch with jenkins shell
  • How can I make resolving git merge conflicts easier on command line
  • Change the author for commits with specific message
  • access() says file exists but fopen() says it does not
  • One Solution collect form web for “Efficient way to find out which branches and/or commits point to an object?”

    You can only “traverse down” the relationship graph as you describe it, but not “back up”, because all object relations in this context are unidirectional associations (i.e. a commit knows only its parents, but not its children; a tree knows its blobs but blobs don’t know what trees reference them).

    The only way to find out which commits include a specific blob is thus to traverse the complete history graph (the entry points are your named refs, i.e. branches and tags).

    This is the same thing that git gc does to determine orphaned objects to be garbage-collected.

    Git Baby is a git and github fan, let's start git clone.