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

Ever edited a file and wondered when it got added to your repository? Or do you just want to know which commits changed a file. This command does the job for you.

git log --follow --oneline filename

Of course, filename is the full filepath along with the filename. Also, if you just need the commit hashes and not the commit message, use this command.

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

That lists the short commit hash. To see the full commit hash, just change the formatting parameter 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 *