Reputation: 420
Is it possible to search for git commit message in many repositories on a git server?
thanks
Upvotes: 1
Views: 45
Reputation: 14890
The convenient way to go about this is to temporarily aggregate all the remotes in one repo.
Consider REPO_LIST
as the array of (local) paths to the repositories on a git server:
$ mkdir /tmp/aggregate_repo && cd $_ && git init .
$ REPO_LIST=(/path/to/repo1 /path/to/repo2 /path/to/repoN); \
for repo in ${REPO_LIST[@]}; do git remote add $(basename $repo) $repo; done
$ git fetch --all
$ git for-each-ref --format='%(refname)' refs/remotes | \
while read ref; do git log --grep=SEARCH_PATTERN $ref --pretty=oneline; done | \
sort | uniq
This will create an aggregate repo, add all the remotes to search, fetch the remotes, and then for each refname in every remote it will search for SEARCH_PATTERN, listing all the matching commits.
Upvotes: 1