Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Blame see changes after a certain date

Tags:

git

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.

like image 648
Praveen Reddy Avatar asked Mar 01 '17 19:03

Praveen Reddy


People also ask

Does git blame identify a particular commit?

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.

How do I see git blame?

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.

What is git blame ignore revs?

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.

What is star in git blame?

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.


1 Answers

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 '^\^'
like image 126
George Hilliard Avatar answered Sep 30 '22 01:09

George Hilliard