是否可以在我的所有Git远程分支中搜索特定的文件内容(不仅是文件,还包括其中的内容)?
我的遥控器在GitHub上,以防万一...
您可以尝试以下方法:
git grep 'search-string' $(git ls-remote . 'refs/remotes/*' | cut -f 2)
它将在所有远程分支中搜索search-string
。由于符号引用HEAD
是镜像的,因此您可能最终会两次搜索同一提交。希望这不是问题。如果是这样,您可以使用以下方法将其过滤掉:
git grep 'search-string' \
$(git ls-remote . 'refs/remotes/*' | grep -v HEAD | cut -f 2)
如果您需要浏览整个历史记录,也可以尝试:
git grep 'search-string' $(git rev-list --all)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句