diff --git a/src/Config.php b/src/Config.php
index cf9b2042a5897992adf6e8a88d75ba07bb9298a2..e153c0d78f91396971b0bdad2ab87b38cd4eafd4 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -167,7 +167,8 @@ final class Config extends PhpCsFixerConfig
         $fileLocator = new FileLocator($callerPath);
         $composerPackage = new ComposerPackage($fileLocator);
 
-        $gitRepository = new GitRepository($callerPath);
+        $repoPath = self::findGitRepository($callerPath);
+        $gitRepository = new GitRepository($repoPath);
 
         $headerProvider = new FormattedHeaderProvider(
             new ChainTemplateProvider(
@@ -182,4 +183,13 @@ final class Config extends PhpCsFixerConfig
 
         return new self($composerPackage, $headerProvider);
     }
+
+    private static function findGitRepository(string $path): string
+    {
+        while (!is_dir($path . '/.git') && $path !== '/') {
+            $path = basename($path);
+        }
+
+        return $path;
+    }
 }