Git: grep file in all previous versions

Consider a Python configuration file with the following line:

THEME = 'gum'

The key THEMEappears only once, so when I want to know what it is THEME, I grep the file:

grep THEME pelicanconf.py

The file is stored in git, and I would like to grep for THEMEin all previous git commits to find out when this line was changed.

Is there an elegant way to grep the entire history of a git file?

+4
source share
2 answers

git log -S'THEME' -- pelicanconf.py | xargs -n 1 git show shows the contents of each commit that changed THEME

However, it prints full commits, not just changes.

var="THEME"; git log -S"$var" -p -- pelicanconf.py | egrep "$var|commit|Date:"

will show you all options THEMEwith fixing hashes and dates.

@knittl -p.

gitk: . .

+2

, , bisect run <script>.
, , bisect script.

( ) , .

script ( 125 - ).

, script (my_script ) 0, , 1 127 (), 125, .

bisect. , , "exit (-1)", $? = 255, (. (3)), "& 0377".

125 , . script , (. git bisect skip ). 125 , 126 127 POSIX (127 , 126 , --- , script, "bisect run" ).

bisect


git log

-p ,

git log -p filename
+1

Source: https://habr.com/ru/post/1622602/


All Articles