How to find commit (s) that point to a git tree object?

When trying to mirror the repo on a remote server, the server rejects the tree object 4e8f805dd45088219b5662bd3d434eb4c5428ec0. This is not a top-level tree, by the way, but a subdirectory.

How can I find out which commits indirectly reference this tree object, so I can avoid clicking the links that refer to these commits in order to get all the rest of my repo to correctly click?

+4
source share
1 answer

As you noted, you just need to find a fix with what you want tree. If it could be a top-level tree, you will need one additional test, but since it is not, you will not.

Do you want to:

  • (, )
  • commit :

Git "plumbing" grep:

#! /bin/sh
#
#  set these:
searchfor=4e8f805dd45088219b5662bd3d434eb4c5428ec0

startpoints="master"  # branch names or HEAD or whatever
# you can use rev-list limiters too, e.g., origin/master..master

git rev-list $startpoints |
    while read commithash; do
        if git ls-tree -d -r --full-tree $commithash | grep $searchfor; then
            echo " -- found at $commithash"
        fi
    done

, git cat-file -p $commithash , .

, ( -d git ls-tree). blob . grep , , :

040000 tree a3a6276bba360af74985afa8d79cfb4dfc33e337    perl/Git/SVN/Memoize
 -- found at 3ab228137f980ff72dbdf5064a877d07bec76df9

, git cat-file -t blob-or-tree, .

+5
source

Source: https://habr.com/ru/post/1663452/


All Articles