Ci sono pochi problemi con le soluzioni elencate qui (anche accettate).
- Non è necessario elencare tutti gli hash come si otterranno i duplicati, inoltre ci vuole più tempo.
Esso si basa su questo, dove è possibile cercare una stringa "test -f /"
su più rami master
e dev
come
git grep "test -f /" master dev
che è lo stesso
printf "master\ndev" | xargs git grep "test -f /"
va così qui.
Questo trova gli hash per la punta di tutti i rami locali e cerca solo in quei commit.
git branch -v --no-abbrev | awk -F' *' '{print $3}' | xargs git grep "string/regexp"
Se avete bisogno di cercare nelle filiali remote troppo quindi aggiungere -a
:
git branch -a -v --no-abbrev | awk -F' *' '{print $3}' | xargs git grep "string/regexp"
Aggiornamento:
# search in local branches
git branch | cut -c3- | xargs git grep "string"
# search in remote branches
git branch -r | cut -c3- | xargs git grep "string"
# search in all (local and remote) branches
git branch -a | cut -c3- | xargs git grep "string"
# search in branches, and tags
git show-ref | grep -v "refs/stash" | cut -d' ' -f2 | xargs git grep "string"
[git-grep] (http://www.kernel.org/pub/software/scm/git/docs/git-grep.html) potrebbe essere quello che stai cercando, ma non sono ancora sicuro quale opzioni di cui avresti bisogno ... – johnny
Possibile duplicato di [Come eseguire il grep (search) codice commit nella cronologia git?] (https://stackoverflow.com/questions/2928584/how-to-grep-search-committed- code-in-the-git-history) – nekketsuuu