23 de septiembre de 2013

Find out when a line was introduced or deleted in GIT history

Hi!

Did you ever come across a line of code that you d *really* like to know when was introduced/deleted ?

Well, if you are using GIT for your project this might come handy.

Let's say the piece of text you are investigating is this:

a = get_something(some_var)

and it is located in the file some_folder/some_file.py

Then, try this command:

git log -S "a = get_something(some_var)" some_folder/some_file.py

Then, GIT will look for the string we specified string within the commit history and output something like this:

commit
Author: Some Dude <
some.dude@mail.com>
Date:   Fri Feb 15 14:09:18 2013 -0300
    The commit message of this commit.

This came quite handy to me recently. Hope it helps!

2 comentarios:

humitos dijo...

chango! si querés que alguien lea tu blog... AUMENTALE LA LETRA! Joder!

BTW, muy bueno el post!... luego de 6 Ctrl++

Matías dijo...

Jajajaja! No ser por qué se publicó con letra en 10pt. Ahí la agrandé.

Igual, se veía bien, che! :)


Abrazo, Humitos!