2009-08-10 132 views
0

你怎么可以搜索所有GIT的标识在您的计算机?要找到一个Git回购其ID

我在Github上创建了一个Git仓库。我的一个文件夹有一个箭头和一个与f1f633类似的图形。我知道回购是我的其他回购之一。

不过,我想能够搜索回购。 我在Github和Google搜索了这个图,但没有成功。

也许,有一些工具,它可以让我搜索的所有ID在我的计算机上的Git。

+2

这不属于SU。 – MicTech 2009-08-10 14:30:16

+0

请将它移动到Stackoverflow。 – 2009-08-10 15:32:08

回答

3

做到这一点最简单的方法是,每个仓库内,使用git cat-file -e检查仓库有对象:

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

只是在你的机器上的所有Git仓库内运行的任何方式结合起来,例如:

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

您也可以使用其他形式的git cat-file以获得有关对象的详细数据;详情请参阅手册。

1

一个解决方案是将查找与“git rev-parse - 验证”或“git cat-file -e”相结合;假设你有非裸库只:

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 

请注意,您应该检查是否找到的对象是你的搜索内容与“混帐秀f1f633”,因为不同的库可以具有相同前缀的不同对象(部分SHA-1)。