Handle git dependencies with relative pub cache (#4494)

diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart
index 2c753c6..b0fda4b 100644
--- a/lib/src/source/git.dart
+++ b/lib/src/source/git.dart
@@ -916,6 +916,7 @@
 }
 
 String _gitDirArg(String path) {
+  path = p.absolute(path);
   final forwardSlashPath =
       Platform.isWindows ? path.replaceAll('\\', '/') : path;
   return '--git-dir=$forwardSlashPath';
diff --git a/pubspec.lock b/pubspec.lock
index da40feb..cc88a70 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -479,4 +479,4 @@
     source: hosted
     version: "2.2.2"
 sdks:
-  dart: ">=3.6.0 <4.0.0"
+  dart: ">=3.7.0-0 <4.0.0"
diff --git a/test/get/git/check_out_test.dart b/test/get/git/check_out_test.dart
index d3a2020..0a79b4d 100644
--- a/test/get/git/check_out_test.dart
+++ b/test/get/git/check_out_test.dart
@@ -51,6 +51,38 @@
     expect(packageSpec('foo'), isNotNull);
   });
 
+  test('checks out a package from Git with relative pub cache', () async {
+    ensureGit();
+
+    await d.git(
+      'foo.git',
+      [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+    ).create();
+
+    await d.appDir(
+      dependencies: {
+        'foo': {'git': '../foo.git'},
+      },
+    ).create();
+
+    await pubGet(
+      environment: {
+        'PUB_CACHE': './pub_cache/',
+      },
+    );
+
+    await d.dir(appPath, [
+      d.dir('pub_cache', [
+        d.dir('git', [
+          d.dir('cache', [d.gitPackageRepoCacheDir('foo')]),
+          d.gitPackageRevisionCacheDir('foo'),
+        ]),
+      ]),
+    ]).validate();
+
+    expect(packageSpec('foo')['rootUri'], startsWith('../pub_cache/git/foo-'));
+  });
+
   test('checks out a package from Git using non-json YAML', () async {
     ensureGit();