Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git to show last changes of a file

Tags:

git

diff

I googled about this and a lot of articles showing how to see changes in either last few days or last commits.

What I really want is to see the last change to a file regardless when and which commit.

Lets say, I have FileA and FileB

commit 1: changed FileA and FileB

commit 2~99: changed FileB

What I want to see is what was the last change to FileA without knowing which commit affected FileA.

This is particularly useful (at least for me) when I git pull a shared project, I see a big list of files changed by a number of commits, I am interested what changes have been made to some of the files, but it's kind of hard to do.

like image 839
James Lin Avatar asked Dec 11 '25 01:12

James Lin


1 Answers

I would simply try

git log -1 -p -- path/to/your/file

Like git help says:

  -<n>
       Limits the number of commits to show. Note that this is a commit
       limiting option.

  [--] <path>...
      Show only commits that are enough to explain how the files that
      match the specified paths came to be. See "History Simplification"
      below for details and other simplification modes.
like image 152
Guillaume Polet Avatar answered Dec 13 '25 16:12

Guillaume Polet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!