See Changes applied to specified lines of code in a given Git commit?

I am currently analyzing a Git repo, and I am trying to figure out how code entered into a specific commit can evolve over time in subsequent commits. For example, given line 9 in commit 57176a ..., what is the next commit in the main branch that modifies this line of code?

As far as I know, git log and git blame work in a different direction: they can parse a string in a given commit based on the previous ones . However, what I would like to do is parse the string in a given commit based on subsequent ones .

+7
git
source share
1 answer

The --reverse option for git blame can help you. If you run this:

 git blame -L 9,9 --reverse 57176a..master your_file_name 

git will start with the specified commit and search forward in the history until line 9 changes. The output will show the last commit in which the line has not changed.

+6
source share

All Articles