Glide
Glide

Reputation: 21245

Find out which commit removed a particular word/line in GIT

With both GIT tools and command line, what is the easiest way to find out which commit removed a particular word from a file?

Upvotes: 12

Views: 3892

Answers (3)

BenC
BenC

Reputation: 8976

You could use the methods described in this post:

If you know the contents of the line, this is an ideal use case for:

git log -S<string> path/to/file
git log -G<regex> path/to/file

Or you could try:

git blame --reverse

Upvotes: 13

uday
uday

Reputation: 8710

Type gitk in command line it would show the graphical tool for comparisons of the file.

(OR)

   $ git log -p

One of the more helpful options is -p, which shows the diff introduced in each commit.

Upvotes: 0

Waynn Lue
Waynn Lue

Reputation: 11375

git blame will show you the most recent commit that changed each line of a file. You can use that on your file, and then go to the line where your word is.

Upvotes: 1

Related Questions