Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to commit file modification time with Git

Tags:

git

Can I commit file modification changes with Git? For example, I touched the file test.txt (touch test.txt) which changes the timestamp without changing its content. Now, can I commit this change in file modification time with Git?

I need to synchronize the timestamp of files between my local and remote repository.

The topic Restore a file's modification time in Git doesn't solve this problem. Actually they are complete opposite. While that topic talks about restoring timestamps after a successful commit, this topic wants to commit only the timestamp (not any change in content, which is not Git's default behavior), i.e a git commit command should detect a change in the timestamp and perform commit even if there is no change in the content.

like image 868
Jahid Avatar asked Sep 20 '25 18:09

Jahid


1 Answers

Ok, this is totally blue sky, but if you

  • Created a file to hold timestamps
  • Created a clean filter to build that file and commit it
  • Created a smudge filter to read that file and update timestamps on checkout

I think you could make this happen. Obviously it's totally roll-your-own, but it seems like a possibility.

like image 80
2 revs, 2 users 80%Erick G. Hagstrom Avatar answered Sep 22 '25 13:09

2 revs, 2 users 80%Erick G. Hagstrom