diff --git a/src/Git/GitRepository.php b/src/Git/GitRepository.php
index 50a4d0a4f21f0b573ccd49e0643157ecacd098b0..317dfacece6faf99bfb67857c27cc178d1931592 100644
--- a/src/Git/GitRepository.php
+++ b/src/Git/GitRepository.php
@@ -45,12 +45,21 @@ final class GitRepository implements GitRepositoryInterface
      */
     public function getYearRange(): string
     {
-        $last = date('Y');
-        $first = exec('git -C ' . escapeshellarg($this->repositoryPath) . ' log --format=%cd --date=format:%Y --date-order | tail -n1');
-        if (!$first) {
-            $first = '???';
+        $years = [];
+        exec(
+            sprintf(
+                'git -C %s log --format=%%cd --date=format:%%Y --date-order %s | sed \'1p;$p;d\'',
+                escapeshellarg($this->repositoryPath),
+                escapeshellarg($this->getHeadCommit())
+            ),
+            $years
+        );
+        if (!$years) {
+            return '???';
         }
+        $last = trim(array_shift($years));
+        $first = $years ? trim(array_pop($years)) : $last;
 
-        return ($last !== null && $last !== $first) ? "$first-$last" : $first;
+        return $last !== $first ? "$first-$last" : $first;
     }
 }