tags:

views:

50

answers:

2

How can you search all GIT's IDs in your computer?

I created a Git repo at Github. One of my folders has an arrow and a similar figure as f1f633. I know that the repo is one of my other repos.

However, I would like to be able to search repo. I searched the figure at Github and at Google unsuccessfully.

Perhaps, there is some tool which allows me to search all IDs in my computer by Git.

+3  A: 

The easiest way to do it is to, within each repository, use git cat-file -e to check if the repository has that object:

git cat-file -e f1f633 2>/dev/null && echo "found"

Just combine it with any way of running within all git repositories in your machine, for instance:

find / -name objects | fgrep .git/objects | while read dir; do
    (cd "$dir" && git cat-file -e f1f633 2>/dev/null && echo "found: $dir")
done

You can also use other forms of git cat-file to get more data about the object; see the manual for details.

CesarB
+1  A: 

One solution would be to combine find with "git rev-parse --verify" or "git cat-file -e"; assuming that you have non-bare repositories only:

find / -name ".git" -type d -print |
while read repo; do
    git --git-dir="$repo" cat-file -e f1f633 2>/dev/null && echo "found: $repo"
done

Note that you should check if found object is what you searched for with "git show f1f633", as different repositories can have different objects with the same prefix (partial SHA-1).

Jakub Narębski