How to check if one file is newer than another in git?

Member

by rollin , in category: Third Party Scripts , 3 months ago

How to check if one file is newer than another in git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by ryan.murray , 3 months ago

@rollin 

You can compare the timestamps of two files in git to check which one is newer using the following command:

1
git log -1 --format="%at" -- <file_path>


Replace <file_path> with the path to the file you want to check. This command will give you the timestamp of the latest commit that modified the file. You can compare the timestamps of two files to determine which one is newer.