Using git blame, is it possible to see only changes made after a certain date on a file?
I am trying to run, git blame on a file with over 10000 lines and a large commit history. Its hard to spot only recent changes using git blame.
The git blame command is used to know who/which commit is responsible for the latest changes made to a file. The author/commit of each line can also been seen. There are many other options for blame, but generally these could help.
If you click on any file in Github you can see the blame option. Using that option, you can see the entire git revision of that file. Below is an example of blame in Github. Git blame is a very effective tool that helps you to learn the entire git history of the file line by line.
git-blame-ignore-revs . It expects one commit hash per line, and all commits in the file will be ignored by git blame . You can add comments to this file by prefixing it with a # , and I'd recommend commenting each sha to explain why it's being skipped. $ cat .git-blame-ignore-revs. # Upgrade to Prettier 2.0.
Annotations for lines modified in the current revision, are marked with bold type and an asterisk. But I think it is important to clarify that this refers to lines modified in the current revision of the file, not the current revision of the repository.
Read the Specifying Ranges section of the git-blame manual. Specifically, you're interested in the --since
option:
When you are not interested in changes older than [...] 3 weeks [for the file
foo
], you can use revision range specifiers similar to git rev-list:git blame --since=3.weeks -- foo
When revision range specifiers are used to limit the annotation, lines that have not changed since the range boundary ([...] the most recent commit that is more than 3 weeks old in the above example) are blamed for that range boundary commit.
So essentially any line that was modified before the time you specify will begin with a ^
character, because that is the marker for the range boundary.
You can then use grep
to filter out lines beginning with ^
:
git blame --since=3.weeks -- foo | grep -v '^\^'
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