2013-06-14 12 views
5

Supponiamo di avere un file bar.cpp che ho inserito in git. Qualche volta, in passato, avevo uno foo in quel file.Come trovo tutte le revisioni git di un file che contiene pippo?

DOMANDA

Come faccio a trovare tutte le revisioni git di bar.cpp che contengono quella stringa foo?

NOTA

Una soluzione da riga di comando sarebbe grande.

+0

Vuoi * tutte * le revisioni contenenti 'foo' o possa 'git bisect' e' grep' do? – Ryan

+0

@minitech se posso iniziare trovando le * ultime * o le revisioni più recenti che contengono 'pippo', farebbe un lungo cammino (btw, non ho familiarità con' git bisect'). – kfmfe04

+0

'git bisect esegui grep foo bar.cpp' era la mia idea, ma @ StevenPenny sembra meglio :) – Ryan

risposta

4

Può usare the pickaxe

git log -S foo bar.cpp 

e se si desidera che le diff

git log -p -S foo bar.cpp 

Maggiori informazioni

 
-S<string> 

    Look for differences that introduce or remove an instance of 
    <string>. Note that this is different than the string simply 
    appearing in diff output; see the pickaxe entry in gitdiffcore(7) 
    for more details. 
+0

+1 fantastico:' -p -S' funziona alla grande – kfmfe04

Problemi correlati