0

I Know in file foo.cpp Following Line has been added some time this year

if(engL.showPrompt()>engL.lessPrompt())
     executeScript();

How to find which commit pushed this change?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • possible duplicate of [git, commit log for specific \_line\_ in file?](http://stackoverflow.com/questions/8435343/git-commit-log-for-specific-line-in-file) – gpoo Feb 01 '13 at 05:12

2 Answers2

4

git blame foo.cpp will show you line by line what commit was the last one to contribute to that line.

Rob Di Marco
  • 43,054
  • 9
  • 66
  • 56
  • with git blame the problem is it talks about from begining which is three year old in my case. and you need to go through every line of code to find. So I was thinking if there is way if I simply pass one line of text like executeScript(); and it gives me the commit number – Efan Harris Feb 01 '13 at 05:59
  • @EfanHarris See `-L` of `git blame`. It allows you to specify a line range or a regex to search for. – Petr Feb 17 '13 at 21:01
3

If the change is not in the last commit, you can use

git log -S"if(engL.showPrompt()>engL.lessPrompt()) executeScript()" -- path/to/file
Michael Wild
  • 24,977
  • 3
  • 43
  • 43