How to find out in which commit a particular code was added?

前端 未结 5 709
执念已碎
执念已碎 2020-12-22 22:13

I want to find out in which commit did I add the code given below:

if (getListView().getChildCount() == 0)
                getActivity().findViewById(androi         


        
5条回答
  •  庸人自扰
    2020-12-22 22:49

    git log -S "mention here line of code" [file-path]    
    

    For example:

    git log -S "First line" test.txt         
    

    Providing the file name with its path is obvious because, most of the time, we want to know who introduced a particular code segment in a particular file.

提交回复
热议问题