DEV Community

Rafael Goulart
Rafael Goulart

Posted on

When a programmer is born

When Microsoft open-sourced Microsoft GW-Basic using a 38 years commit, I thought: how is that possible?

Well, you can use an old computer, set a date in the past, commit. But it can be done with some bash and Git tricks.

A magic touch

touch command allow us to create empty files and mess with the timestamp. So you can do:

$ touch -d '1972-11-28 13:25:00 -0300' README.md
$ ls -l
-rw-rw-r-- 1 rafael rafael    0 nov 28  1972 README.md

The time-machine versioning

GIT has two dates related to a commit: GIT_COMMITTER_DATE and GIT_AUTHOR_DATE. According to Git documentation;

  • GIT_AUTHOR_DATE: The date used for the author's identity when creating commit or tag objects, or when writing reflogs.
  • GIT_COMMITTER_DATE: The date used for the committer identity when creating commit or tag objects, or when writing reflogs.

Basically, the first affects the commit date (seen on git log or on Github commit listing) and the second affects the file date. You need to change both to get the complete effect.

GIT_AUTHOR_DATE can be set during the commit or amending a commit. GIT_COMMITTER_DATE must be in the environment to be considered. It's also possible to change them after (but that's harder, it can take a long time for big repositories).

Jumping into the DeLorean

This small script glues the pieces together. It's supposed to run on a brand new folder, with any set of files you want.

#!/bin/bash
DATE="1955-11-12 22:04 -0500"
touch -d "${DATE}" README.md
touch -d "${DATE}" lightning-on-the-clock.DOC
touch -d "${DATE}" any-other-file-you-want
git init
git add .
export GIT_COMMITTER_DATE=$DATE
git commit --date "${DATE}" -m "Initialize programmer"
unset GIT_COMMITTER_DATE

Programmers' commit date

Just for fun, I create a repository using my birth date. You can clone and create your own born repository!

https://github.com/rafaelgou/born

That's all for today.

Top comments (0)