2013-11-11

How to create Git commits dated based on last-modification time of involved files

This blog post explains how to create Git commits dated based on last-modification time of involved files.

git commit creates the commit with the date taken from the current system date. Sometimes, especially if old versions of files are added to git, it's preferable to create a commit whose date is based on last-modification time of involved (i.e. non-deleted) files. There is no built-in Git command for that. As a workaround, it's possible to specify git commit --date=... ... manually, but it would be nicer if the time was autodetected as the maximum of the last-modification times of the files involved.

The git-dcommit tool tool can be used to automate that. Download the script from here, make it executable, add it to your $PATH, and use git dcommit ... instead of git commit ... . The tool is written in Python, and it needs a Unix system such as Linux. It shouldn't be hard do port it to Windows.

No comments: