title: Get date of oldest git commit since last git tag
body: <p>I'm trying to find what is the oldest git commit date since the git tag released. I found this other SO question <a href="https://stackoverflow.com/questions/12082981/get-all-git-commits-since-last-tag">Get all git commits since last tag</a> and from there I tried this command (where <code>&lt;tag_name&gt;</code> is obviously my tag name).</p>
  <p>I first wrote the question with the format <code>%cI</code> but it should be <code>%aI</code> for the author ref <strong>not</strong> the commiter ref (thanks to @torek for pointing this out)</p>
  <pre class="lang-bash prettyprint-override"><code>git log -1 &lt;tag_name&gt;..HEAD --format=&quot;%aI&quot;
  </code></pre>
  <p>but this returns the latest commit, not the older commit</p>
  <p>ok then I tried to reverse the full list</p>
  <pre class="lang-bash prettyprint-override"><code>git log &lt;tag_name&gt;..HEAD --format=&quot;%aI&quot; --reverse
  </code></pre>
  <p>and I can see the oldest commits showing on the top but then if I add the max count of <code>-1</code>, well it doesn't work and the reason is because the reverse is only applied <strong>after</strong> retrieving <code>n</code> count, so I still get the newest instead of the oldest</p>
  <p>I saw someone posting this command, but that doesn't work on windows terminal, so I cannot use this command since I'm looking for a universal command (<strong>it has to work on all OS</strong>)</p>
  <pre class="lang-bash prettyprint-override"><code>git log --reverse --format=%aI | head -n 1
  </code></pre>
  <p>So what git command, that works on any OS, can I use to show me the oldest git commit date since my last release tag? By the way I ran an extra git command to get the last tag, if somehow we can it all in 1 git command instead of 2, that would be even more wonderful.</p>
  <p>The reason I need to find the oldest commit date is that I want to use it <a href="https://github.com/ghiscoding/lerna-lite" rel="nofollow noreferrer">Lerna-Lite</a> for a new feature to show commit author login username in a changelog &amp; github release, and that is only available by querying the GitHub Graphql API to return all commit details and I obviously don't want to query commits that were already released. So I need to be precise when querying from a given date so that it returns the exact amount of data needed and nothing more, hence the need to know the exact date timestamp of the oldest commit since the last release.</p>
  <p>EDIT</p>
  <p>To be clear, I'm really looking for the oldest commit date since last tag release and I'm <strong>not</strong> looking for the tag date. My scenario is that if I create a Pull Request while being in <code>v1.0.0</code> tag but only merge it <strong>after</strong> the release of <code>v1.1.0</code> then the commit becomes older than the tag date and so I'm not seeing the commit that was merged because it's older than the tag itself, however I do see it in the git log list.</p>
  <p>Also I'm looking for a cross environment command that does <strong>not</strong> include any <code>|</code> or <code>&amp;</code> because that unfortunately does not work on Windows because we cannot pipe commands on Windows :(</p>
  <p>EDIT 2 (alternative solution for now)</p>
  <p>So in Lerna-Lite, we use <a href="https://www.npmjs.com/package/execa" rel="nofollow noreferrer">execa</a> to query git in JS/TS, and with that I found an alternative (but is far from being performant). If I use the git log reverse (without the <code>-1</code> count) then it returns a complete list of all commits which <code>execa</code> returns as a long string and from there I can simply do a string split of <code>\n</code> and get only the first split match which is what I want. The main downside, like I said, is that it's not performant at all and is probably equivalent to using the unix pipe command <code>git log --reverse | head -n 1</code>.</p>
  <pre class="lang-js prettyprint-override"><code>const lastTagName = 'v1.1.0';
  const stdout = execa.sync('git', ['log', `${lastTagName}..HEAD`, '--format=&quot;%aI&quot;', '--reverse']).stdout;
  const [oldestCommitInfo] = stdout.split('\n');
  </code></pre>
  <p>This works and I'll use that for now but I still wish to find a better solution that is much more performant than this alternative and that would for all OS</p>