I use git blame
command to see in which commit have been added some particular code line, but sometimes I bump into the same problem: someone has made some kind of code formatting, or has changed function interface and refreshed all client code.
Eventually git blame show me only this last commit on particular code line. How ignore this commit and see what happened before it?
Of course I can checkout on commit before format-edited commit and see blame again, but it may take a lot of time on huge project and doesn't appropriate.
In your repository, create a file to hold commit hashes of commits to be ignored by git blame . Naming this file . git-blame-ignore-revs seems to be a common convention. This causes git to automatically ignore the commits specified in that file for every call to git blame .
You can also quit the git blame window using the q key on your keyboard. Now, if you want to learn more about what changed in a commit, simply copy the commit hash and use git log as follows. You should be able to see the full commit message, what lines are removed and what lines are added since the commit before it.
Summary. The git blame command is used to examine the contents of a file line by line and see when each line was last modified and who the author of the modifications was. The output format of git blame can be altered with various command line options.
From git-blame: Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision. When specified one or more times, -L restricts annotation to the requested lines.
I think you are looking for the -w option that excludes white space. According to the man page.
Ignore whitespace when comparing the parent’s version and the child’s to find where the lines came from.
Moved code can also be excluded. See the -M and -C options. See https://git-scm.com/docs/git-blame
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With