1diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart
2index 9f33a22cc3..c46255742c 100644
3--- a/dev/bots/prepare_package.dart
4+++ b/dev/bots/prepare_package.dart
5@@ -602,7 +602,7 @@ class ArchiveCreator {
6
7 Future<String> _runGit(List<String> args, {Directory? workingDirectory}) {
8 return _processRunner.runProcess(
9- <String>['git', ...args],
10+ <String>['git', '--git-dir', '.git', ...args],
11 workingDirectory: workingDirectory ?? flutterRoot,
12 );
13 }
14diff --git a/packages/flutter_tools/lib/src/commands/downgrade.dart b/packages/flutter_tools/lib/src/commands/downgrade.dart
15index a58b75c009..02da0daeb7 100644
16--- a/packages/flutter_tools/lib/src/commands/downgrade.dart
17+++ b/packages/flutter_tools/lib/src/commands/downgrade.dart
18@@ -120,7 +120,7 @@ class DowngradeCommand extends FlutterCommand {
19 // Detect unknown versions.
20 final ProcessUtils processUtils = _processUtils!;
21 final RunResult parseResult = await processUtils.run(<String>[
22- 'git', 'describe', '--tags', lastFlutterVersion,
23+ 'git', '--git-dir', '.git', 'describe', '--tags', lastFlutterVersion,
24 ], workingDirectory: workingDirectory);
25 if (parseResult.exitCode != 0) {
26 throwToolExit('Failed to parse version for downgrade:\n${parseResult.stderr}');
27@@ -192,7 +192,7 @@ class DowngradeCommand extends FlutterCommand {
28 continue;
29 }
30 final RunResult parseResult = await _processUtils!.run(<String>[
31- 'git', 'describe', '--tags', sha,
32+ 'git', '--git-dir', '.git', 'describe', '--tags', sha,
33 ], workingDirectory: workingDirectory);
34 if (parseResult.exitCode == 0) {
35 buffer.writeln('Channel "${getNameForChannel(channel)}" was previously on: ${parseResult.stdout}.');
36diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart
37index 0702b35e7e..36b2a95b65 100644
38--- a/packages/flutter_tools/lib/src/version.dart
39+++ b/packages/flutter_tools/lib/src/version.dart
40@@ -407,7 +407,7 @@ abstract class FlutterVersion {
41 /// wrapper that does that.
42 @visibleForTesting
43 static List<String> gitLog(List<String> args) {
44- return <String>['git', '-c', 'log.showSignature=false', 'log'] + args;
45+ return <String>['git', '--git-dir','.git', '-c', 'log.showSignature=false', 'log'] + args;
46 }
47 }
48
49@@ -559,7 +559,7 @@ class _FlutterVersionGit extends FlutterVersion {
50 String? get repositoryUrl {
51 if (_repositoryUrl == null) {
52 final String gitChannel = _runGit(
53- 'git rev-parse --abbrev-ref --symbolic $kGitTrackingUpstream',
54+ 'git --git-dir .git rev-parse --abbrev-ref --symbolic $kGitTrackingUpstream',
55 globals.processUtils,
56 flutterRoot,
57 );
58@@ -567,7 +567,7 @@ class _FlutterVersionGit extends FlutterVersion {
59 if (slash != -1) {
60 final String remote = gitChannel.substring(0, slash);
61 _repositoryUrl = _runGit(
62- 'git ls-remote --get-url $remote',
63+ 'git --git-dir .git ls-remote --get-url $remote',
64 globals.processUtils,
65 flutterRoot,
66 );
67@@ -952,7 +952,7 @@ class GitTagVersion {
68 }
69 // find all tags attached to the given [gitRef]
70 final List<String> tags = _runGit(
71- 'git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n');
72+ 'git --git-dir .git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n');
73
74 // Check first for a stable tag
75 final RegExp stableTagPattern = RegExp(r'^\d+\.\d+\.\d+$');
76@@ -973,7 +973,7 @@ class GitTagVersion {
77 // recent tag and number of commits past.
78 return parse(
79 _runGit(
80- 'git describe --match *.*.* --long --tags $gitRef',
81+ 'git --git-dir .git describe --match *.*.* --long --tags $gitRef',
82 processUtils,
83 workingDirectory,
84 )