diff --git a/src/Config.php b/src/Config.php
index e153c0d78f91396971b0bdad2ab87b38cd4eafd4..f4245f6761531e3ee596277978247544af9d86f1 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -187,7 +187,7 @@ final class Config extends PhpCsFixerConfig
     private static function findGitRepository(string $path): string
     {
         while (!is_dir($path . '/.git') && $path !== '/') {
-            $path = basename($path);
+            $path = dirname($path);
         }
 
         return $path;