Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to see all the versions of a file using git?

Tags:

git

I often have a need to find something I coded in an old version of script but I don't know when. I usually try to jump around in the log finding different versions and seeing if they have the change, or I just give up and try something else.

What would be particularly useful is a command that outputs every version of a file between two dates or hashes. Then an easy grep would find what I'm looking for.

It would probably work something like this:

git showeverything d612905a..b39af32e /path/to/file /tmp/output
like image 208
Matt Avatar asked Oct 21 '25 03:10

Matt


1 Answers

git has the perfect tool for this: git log -S which will search for a change and only show those commits

# search changes in all branches which touch the string $abc in a file
git log -p -S'$abc' --all -- path/to/file
like image 115
knittl Avatar answered Oct 23 '25 18:10

knittl