How to see which git commits modified or added a file.

Ever edited a file and won­dered when it got added to your repos­i­tory? Or do you just want to know which com­mits changed a file. This com­mand does the job for you.

git log --follow --oneline filename

Of course, file­name is the full filepath along with the file­name. Also, if you just need the com­mit hashes and not the com­mit mes­sage, use this command.

git log --pretty=format:'%h' --follow filename

That lists the short com­mit hash. To see the full com­mit hash, just change the for­mat­ting para­me­ter from h, to H as shown below

git log --pretty=format:'%H' --follow filename

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *