如何解决颤振问题-致命:不是git存储库

如何解决颤振问题-致命:不是git存储库,git,flutter,android-studio,Git,Flutter,Android Studio,我是一个新手,从几周前开始就被困在一个地方。我已经在其他几台机器上使用Flutter/Android Studio做了一些简单的项目,这个问题并不存在。它很好用。我想在我的主计算机上使用此软件,而不使用远程桌面。。。我的操作系统是Windows10 每次我点击任何颤振命令时,我都会收到相同的错误: fatal: not a git repository (or any of the parent directories): .git Building flutter tool... Runnin

我是一个新手,从几周前开始就被困在一个地方。我已经在其他几台机器上使用Flutter/Android Studio做了一些简单的项目,这个问题并不存在。它很好用。我想在我的主计算机上使用此软件,而不使用远程桌面。。。我的操作系统是Windows10

每次我点击任何颤振命令时,我都会收到相同的错误:

fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
以下解决方案对我不起作用:

  • 删除./pub缓存文件夹,pub缓存修复
  • git初始化/git克隆
  • 扑通
  • 颤振创建--sample=material.AppBar.1 mysample
  • 从其他计算机复制工作项目
  • 从项目目录运行命令,例如C:\Users\User\AndroidStudioProjects\MyProject\
  • 重新安装我使用的所有东西:flatter、androidstudio、Git
  • 禁用防病毒/从隔离区删除颤振文件
  • 可能还有其他人
2021年5月18日编辑 我发现在我的主机上一切都正常,但在登录到其他windows用户帐户之后。因此,我的用户设置可能有问题。 我试图删除我的用户目录C:\Users\user中与dart/flatter/android相关的所有内容。之后,我删除了F:\src目录,再次卸载git,克隆了颤振。不幸的是,错误仍然发生。。。我不知道我还能做什么在配置文件中看起来是一个简单的更改,但是哪一个?

Git命令看起来工作正常,例如

C:\>git --version
git version 2.30.1.windows.1
Git状态

F:\src\flutter>git status
On branch stable
Your branch is up to date with 'origin/stable'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .knownPackages
        .pub-cache_old/
        .temp/
        build-tools/
        emulator/
        licenses/
        patcher/
        platform-tools/
        platforms/
        sdk/
        skins/
        sources/
        system-images/
        tools/

nothing added to commit but untracked files present (use "git add" to track)
颤振医生-vv:

F:\src\flutter>flutter doctor -vv
fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
[ +111 ms] executing: [F:\src\flutter/] git -c log.showSignature=false log -n 1
--pretty=format:%H
[ +107 ms] Exit code 0 from: git -c log.showSignature=false log -n 1
--pretty=format:%H
[   +1 ms] a5cdb02597b2f35c484238501982a987f7c70c60
[   +1 ms] executing: [F:\src\flutter/] git tag --points-at
a5cdb02597b2f35c484238501982a987f7c70c60
[  +74 ms] Exit code 0 from: git tag --points-at
a5cdb02597b2f35c484238501982a987f7c70c60
[   +2 ms] executing: [F:\src\flutter/] git describe --match *.*.* --long --tags
a5cdb02597b2f35c484238501982a987f7c70c60
[ +100 ms] Exit code 0 from: git describe --match *.*.* --long --tags
a5cdb02597b2f35c484238501982a987f7c70c60
[   +1 ms] 2.0.6-1-ga5cdb02597
[  +66 ms] executing: [F:\src\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +67 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [F:\src\flutter/] git ls-remote --get-url origin
[  +58 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +104 ms] executing: [F:\src\flutter/] git rev-parse --abbrev-ref HEAD
[  +73 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[ +102 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required,
skipping update.
[   +2 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required,
skipping update.
[   +2 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping
update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +5 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping
update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping
update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping
update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required,
skipping update.
[  +70 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[   +1 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping
update.
[   +1 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping
update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping
update.
[   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping
update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +3 ms] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping
update.
[   +1 ms] Artifact Instance of 'PubDependencies' is not required, skipping update.
[  +23 ms] executing: [F:\src\flutter/] git rev-parse --abbrev-ref HEAD
[  +67 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] stable
[   +1 ms] Skipping request to fetchTags - on well known channel stable.
[        ] executing: [F:\src\flutter/] git tag --points-at HEAD
[  +71 ms] Exit code 0 from: git tag --points-at HEAD
[   +1 ms] executing: [F:\src\flutter/] git describe --match *.*.* --long --tags
HEAD
[  +85 ms] Exit code 0 from: git describe --match *.*.* --long --tags HEAD
[   +1 ms] 2.0.6-1-ga5cdb02597
[  +12 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +183 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java
-version
[   +2 ms] openjdk version "11.0.8" 2020-07-14
           OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
           OpenJDK 64-Bit Server VM (build 11.0.8+10-b944.6842174, mixed mode)
[  +12 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +187 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java
-version
[   +2 ms] openjdk version "11.0.8" 2020-07-14
           OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
           OpenJDK 64-Bit Server VM (build 11.0.8+10-b944.6842174, mixed mode)
[  +20 ms] executing: [F:\src\flutter/] git -c log.showSignature=false log -n 1
--pretty=format:%ar
[  +62 ms] Exit code 0 from: git -c log.showSignature=false log -n 1
--pretty=format:%ar
[   +1 ms] 26 minutes ago
[  +77 ms] java -version
[  +25 ms] executing: F:\src\flutter\platform-tools\adb.exe devices -l
[  +34 ms] [√] Flutter (Channel stable, 2.0.7-0.0.pre.1, on Microsoft Windows
[Version
               10.0.19042.928], locale pl-PL)
[   +4 ms]     • Flutter version 2.0.7-0.0.pre.1 at F:\src\flutter
[   +2 ms]     • Framework revision a5cdb02597 (26 minutes ago), 2021-05-14
15:23:36 +0200
[   +1 ms]     • Engine revision 05e680e202
[   +1 ms]     • Dart version 2.12.3
|[ +131 ms] List of devices attached
/[ +134 ms] executing: F:\src\flutter\platform-tools\adb.exe devices -l
-[  +71 ms] List of devices attached
[+5681 ms] [√] Android toolchain - develop for Android devices (Android SDK version
30.0.3)
[   +2 ms]     • Android SDK at F:\src\flutter
[   +1 ms]     • Platform android-30, build-tools 30.0.3
[   +1 ms]     • Java binary at: C:\Program Files\Android\Android
Studio\jre\bin\java
[   +1 ms]     • Java version OpenJDK Runtime Environment (build
11.0.8+10-b944.6842174)
[   +1 ms]     • All Android licenses accepted.
[   +3 ms] [√] Chrome - develop for the web
[   +1 ms]     • Chrome at C:\Program Files
(x86)\Google\Chrome\Application\chrome.exe
[   +3 ms] [√] Android Studio (version 4.1.0)
[   +1 ms]     • Android Studio at C:\Program Files\Android\Android Studio
[   +3 ms]     • Flutter plugin can be installed from:
[        ]        https://plugins.jetbrains.com/plugin/9212-flutter
[        ]     • Dart plugin can be installed from:
[        ]        https://plugins.jetbrains.com/plugin/6351-dart
[   +1 ms]     • Java version OpenJDK Runtime Environment (build
11.0.8+10-b944.6842174)
[   +2 ms] [√] Connected device (2 available)
[   +1 ms]     • Chrome (web) • chrome • web-javascript • Google Chrome
90.0.4430.212
[   +1 ms]     • Edge (web)   • edge   • web-javascript • Microsoft Edge
90.0.818.56
[   +1 ms] • No issues found!
[  +15 ms] "flutter doctor" took 7 075ms.
[ +160 ms] ensureAnalyticsSent: 154ms
[   +3 ms] Running shutdown hooks
[   +1 ms] Shutdown hooks complete
[   +1 ms] exiting with code 0
如果有人能指导我解决问题,我会很高兴的。我希望这是件小事,但我办不到。 问候

2021年5月15日编辑 我提供了C:\directory中所需的pubspec.yaml文件的其他错误,这可能有助于解决此问题:

f:\test>flutter create --sample=material.AppBar.1 mysample
fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Creating project mysample...
  mysample\.gitignore (created)
  mysample\.idea\libraries\Dart_SDK.xml (created)
  mysample\.idea\libraries\KotlinJavaRuntime.xml (created)
  mysample\.idea\modules.xml (created)
  mysample\.idea\runConfigurations\main_dart.xml (created)
  mysample\.idea\workspace.xml (created)
  mysample\.metadata (created)
  mysample\android\app\build.gradle (created)
  mysample\android\app\src\main\kotlin\com\example\mysample\MainActivity.kt (created)
  mysample\android\build.gradle (created)
  mysample\android\mysample_android.iml (created)
  mysample\android\.gitignore (created)
  mysample\android\app\src\debug\AndroidManifest.xml (created)
  mysample\android\app\src\main\AndroidManifest.xml (created)
  mysample\android\app\src\main\res\drawable\launch_background.xml (created)
  mysample\android\app\src\main\res\drawable-v21\launch_background.xml (created)
  mysample\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
  mysample\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
  mysample\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
  mysample\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
  mysample\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
  mysample\android\app\src\main\res\values\styles.xml (created)
  mysample\android\app\src\main\res\values-night\styles.xml (created)
  mysample\android\app\src\profile\AndroidManifest.xml (created)
  mysample\android\gradle\wrapper\gradle-wrapper.properties (created)
  mysample\android\gradle.properties (created)
  mysample\android\settings.gradle (created)
  mysample\ios\Runner\AppDelegate.swift (created)
  mysample\ios\Runner\Runner-Bridging-Header.h (created)
  mysample\ios\Runner.xcodeproj\project.pbxproj (created)
  mysample\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
  mysample\ios\.gitignore (created)
  mysample\ios\Flutter\AppFrameworkInfo.plist (created)
  mysample\ios\Flutter\Debug.xcconfig (created)
  mysample\ios\Flutter\Release.xcconfig (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
  mysample\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
  mysample\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
  mysample\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
  mysample\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
  mysample\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
  mysample\ios\Runner\Base.lproj\Main.storyboard (created)
  mysample\ios\Runner\Info.plist (created)
  mysample\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
  mysample\ios\Runner.xcodeproj\project.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (created)
  mysample\ios\Runner.xcodeproj\project.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (created)
  mysample\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
  mysample\ios\Runner.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (created)
  mysample\ios\Runner.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (created)
  mysample\lib\main.dart (created)
  mysample\mysample.iml (created)
  mysample\pubspec.yaml (created)
  mysample\README.md (created)
  mysample\test\widget_test.dart (created)
  mysample\web\favicon.png (created)
  mysample\web\icons\Icon-192.png (created)
  mysample\web\icons\Icon-512.png (created)
  mysample\web\index.html (created)
  mysample\web\manifest.json (created)
Could not find a file named "pubspec.yaml" in "C:\".
Running "flutter pub get" in mysample...
pub get failed (66; Could not find a file named "pubspec.yaml" in "C:\".)

您使用zip链接而不是git克隆下载了Flatter。至少我认为这是一条信息

尝试转到以下文件夹:

cd F:\src\flutter
然后执行下一个命令

git status
并且可能会说与我在处理非github文件夹时相同的错误

可能您下载了一个固定SDK,教程中对此进行了解释:

如果不想安装安装的固定版本 捆绑,您可以跳过步骤1和2。相反,从 在GitHub上进行颤振回购,并根据需要更改分支或标记。对于 例子:
C:\src>git克隆https://github.com/flutter/flutter.git -b稳定

这就是我在flutter文件夹中执行git status时的状态

很明显,我没有100%升级flifter,因为我正在处理生产中的项目

顺便说一句:我使用mac,所以我的终端非常不同,但想法是一样的

无论如何

flutter clean
flutter --version
flutter pub get
flutter run
....

应该可以工作,但不是flatter——升级,因为需要连接到git项目并下载最新的稳定版本

我也遇到了同样的问题。我修改了命令提示设置。。。我想让命令提示符在特定目录中自动打开,所以我在注册表中添加了一个自动运行选项。这实际上导致了与您在这里看到的相同的错误。您的环境中是否有类似的情况导致命令在错误的目录中运行?作为参考,我必须从路径HKEY_CURRENT_USER\Software\Microsoft\Command Processor中删除密钥自动运行,这解决了我的颤振问题。

嗨,Dani,谢谢你的回复。是的,我从安装了颤振,但git status命令没有给出错误。所以我还在寻找答案。你有正确的路径吗?我的意思是,flatter命令指向flatterSDK?您可能会问我的环境变量。删除Path变量中的条目(F:\src\flatter\bin)后,我收到预期错误C:\>flatter“flatter”未被识别为内部或外部命令、可操作程序或批处理文件。因此,flatter命令指向flatter sdkC:\>其中flatter F:\src\flatter\bin\flatter F:\src\flatter\bin\flatter.batI在C:\directory(flatter create命令)中预期的pubspec.yaml文件中又添加了一个错误!现在一切正常。非常感谢:)
flutter clean
flutter --version
flutter pub get
flutter run
....