ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Figuring Out When a Repo Introduced a String (Like a Trademark)


#1

Suppose you need to know what commit or date some string was introduced into your code. A good example of this is a trademark, but this could apply to any string.

How to find the approximate date and file:

  1. Sync repo to some date
  2. Use command “ag” with the option to ignore node_modules to search for just part of the trademark string in case of returns, formatting, etc. (note, brew install ag if you don’t have ag)

Example

✗ cd <project>

✗ git checkout `git rev-list -n 1 --before="2016-06-01 13:37" master` && ag --ignore node_modules "<some string>" .              
HEAD is now at f84a0bc2d... 
app/views/pages/some-file.html.slim .  13:        <some text result>

✗ git checkout `git rev-list -n 1 --before="2016-04-01 13:37" master` && ag --ignore node_modules "<some string>" .           
Previous HEAD position was f84a0bc2d... 
HEAD is now at f48a1d4ea... 
<nothing shows up>

Then look at the history of the file that matches:

gitk log <some file>