<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rafael Goulart</title>
    <description>The latest articles on DEV Community by Rafael Goulart (@rafaelgou).</description>
    <link>https://dev.to/rafaelgou</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F395280%2F2d5a4d5a-6f9e-451e-8e32-720e123523f0.jpeg</url>
      <title>DEV Community: Rafael Goulart</title>
      <link>https://dev.to/rafaelgou</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rafaelgou"/>
    <language>en</language>
    <item>
      <title>When a programmer is born</title>
      <dc:creator>Rafael Goulart</dc:creator>
      <pubDate>Tue, 26 May 2020 00:48:54 +0000</pubDate>
      <link>https://dev.to/rafaelgou/when-a-programmer-is-born-3do4</link>
      <guid>https://dev.to/rafaelgou/when-a-programmer-is-born-3do4</guid>
      <description>&lt;p&gt;When Microsoft open-sourced &lt;a href="https://github.com/microsoft/GW-BASIC"&gt;Microsoft GW-Basic&lt;/a&gt; using a 38 years commit, I thought: how is that possible?&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  A magic touch
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://linux.die.net/man/1/touch"&gt;touch&lt;/a&gt; command allow us to create empty files and mess with the timestamp. So you can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'1972-11-28 13:25:00 -0300'&lt;/span&gt; README.md
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 rafael rafael    0 nov 28  1972 README.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The time-machine versioning
&lt;/h2&gt;

&lt;p&gt;GIT has two dates related to a commit: &lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt; and &lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt;. According to &lt;a href="https://git-scm.com/docs/git"&gt;Git documentation&lt;/a&gt;;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GIT_AUTHOR_DATE&lt;/strong&gt;: The date used for the author's identity when creating commit or tag objects, or when writing reflogs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GIT_COMMITTER_DATE&lt;/strong&gt;: The date used for the committer identity when creating commit or tag objects, or when writing reflogs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically, the first affects the &lt;em&gt;commit&lt;/em&gt; date (seen on &lt;code&gt;git log&lt;/code&gt; or on Github commit listing) and the second affects the &lt;em&gt;file&lt;/em&gt; date. You need to change both to get the complete effect.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt; can be set during the commit or amending a commit. &lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt; 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).&lt;/p&gt;

&lt;h2&gt;
  
  
  Jumping into the DeLorean
&lt;/h2&gt;

&lt;p&gt;This small script glues the pieces together. It's supposed to run on a brand new folder, with any set of files you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"1955-11-12 22:04 -0500"&lt;/span&gt;
&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; README.md
&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; lightning-on-the-clock.DOC
&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; any-other-file-you-want
git init
git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GIT_COMMITTER_DATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$DATE&lt;/span&gt;
git commit &lt;span class="nt"&gt;--date&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initialize programmer"&lt;/span&gt;
&lt;span class="nb"&gt;unset &lt;/span&gt;GIT_COMMITTER_DATE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Programmers' commit date
&lt;/h2&gt;

&lt;p&gt;Just for fun, I create a repository using my birth date. You can clone and create your own born repository!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rafaelgou/born"&gt;https://github.com/rafaelgou/born&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all for today.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>github</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
