Joh*_*ter 22
你可以试试这个:
git grep 'search-string' $(git ls-remote . 'refs/remotes/*' | cut -f 2)
Run Code Online (Sandbox Code Playgroud)
这将搜索所有远程分支search-string
.由于符号引用HEAD
是镜像的,因此您最终可能会两次搜索相同的提交.希望这不是问题.如果是这样,你可以用以下方法过滤掉它:
git grep 'search-string' \
$(git ls-remote . 'refs/remotes/*' | grep -v HEAD | cut -f 2)
Run Code Online (Sandbox Code Playgroud)
如果您需要深入了解整个历史记录,您还可以尝试:
git grep 'search-string' $(git rev-list --all)
Run Code Online (Sandbox Code Playgroud)
小智 5
假设您正在跟踪所有远程分支,这将在所有提交中进行搜索.
git log --all -p | grep 'search-string'
Run Code Online (Sandbox Code Playgroud)
要跟踪所有远程分支:
for remote in `git branch -r`; do git branch --track $remote; done
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7086 次 |
最近记录: |