Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the last modification data of a file in git repo

Tags:

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

like image 505
HMR Avatar asked Mar 19 '14 06:03

HMR


People also ask

How can I tell when a git file was last updated?

If you want to see only the last change, you can use git log -p -1 -- b .

How do I see what changed in a git file?

To find out which files changed in a given commit, use the git log --raw command.

Which command is used to view the history of all the changes to a file?

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 .

How do I see the last commit of a file?

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.


1 Answers

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.

like image 96
MitchellK Avatar answered Sep 17 '22 18:09

MitchellK