Im trying to find the command to get the last modified date of a file in a local git repo.
Created the repo and have done one commit. Had to edit one file and will commit this file but was wondering what the last modification data of the file in the repo is (not the commit date).
Have no gui onl command line.
git log ./path/to/filename.php
only gives me the commit date
If you want to see only the last change, you can use git log -p -1 -- b .
To find out which files changed in a given commit, use the git log --raw command.
Using git log --follow -p bar will show the file's entire history, including any changes to the file when it was known as foo .
Solution. 2.1 git log to display all the commit_id, the first one is the last commit_id, copy it. 2.2 git show commit_id --name-only to display all the files committed in the specified commit_id. 2.3 Undo the last commit with git reset --soft HEAD~1 , move the mistakenly committed files back to the staging area.
The correct way to do this is to use git log as follows.
git log -1 --pretty="format:%ci" /path/to/repo/anyfile.any)
-1 restricts it to the very last time the file changed
%ci is just one of the date formats you can choose from others here at https://git-scm.com/docs/pretty-formats
This method is fool proof and 100% accurate.
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