Failed to read Git tree: fatal: not a git repository (or any of the parent directories): .git
naveedahmed1 opened this issue · 9 comments
Command
update
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
I just tried updating an Angular project from Angular version 17.3.3
to v 18.0.0-next.6.
After the package install finishes it throws the error fatal: not a git repository (or any of the parent directories): .git
As show in the below log, it says √ Packages successfully installed.
, but soon after that it throws this error:
ng update @angular/cli --create-commits=true --force=true --next
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 18.0.0-next.3 to perform the update.
√ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 54 dependencies.
Fetching dependency metadata from registry...
Package "@angular/pwa" has an incompatible peer dependency to "@angular/cli" (requires "^17.0.0", would install "18.0.0-next.3").
Package "@angular/material" has an incompatible peer dependency to "@angular/animations" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/cdk" has an incompatible peer dependency to "@angular/common" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/cdk" has an incompatible peer dependency to "@angular/core" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/material" has an incompatible peer dependency to "@angular/forms" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/material" has an incompatible peer dependency to "@angular/platform-browser" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Updating package.json with dependency @angular-devkit/build-angular @ "18.0.0-next.3" (was "17.3.3")...
Updating package.json with dependency @angular/cli @ "18.0.0-next.3" (was "17.3.3")...
Updating package.json with dependency @angular/compiler-cli @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency typescript @ "5.4.5" (was "5.3.3")...
Updating package.json with dependency @angular/animations @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/common @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/compiler @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/core @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/forms @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/platform-browser @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/platform-server @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/router @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/service-worker @ "18.0.0-next.6" (was "17.3.3")...
UPDATE package.json (3656 bytes)
√ Packages successfully installed.
fatal: not a git repository (or any of the parent directories): .git
Failed to read Git tree:
fatal: not a git repository (or any of the parent directories): .git
Minimal Reproduction
I assume updating Angular project from Angular version 17.3.3
to v 18.0.0-next.6 should throw this error.
Exception or Error
fatal: not a git repository (or any of the parent directories): .git
Failed to read Git tree:
fatal: not a git repository (or any of the parent directories): .git
Your Environment
Angular CLI: 18.0.0-next.3
Node: 20.11.1
Package Manager: npm 10.5.0
OS: win32 x64
Angular: 18.0.0-next.6
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1800.0-next.3
@angular-devkit/build-angular 18.0.0-next.3
@angular-devkit/core 17.3.3
@angular-devkit/schematics 17.3.3
@angular/cdk 17.3.3
@angular/cli 18.0.0-next.3
@angular/fire 17.0.1
@angular/google-maps 17.3.3
@angular/material 17.3.3
@angular/pwa 17.3.3
@schematics/angular 17.3.3
rxjs 7.8.1
typescript 5.4.5
zone.js 0.14.4
Anything else relevant?
No response
This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app
and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
Thanks @alan-agius4 for your reply. Can you please try it on the repo I shared few days back? Just clone the repo and run this command ng update @angular/cli --create-commits=true --force=true --next
@naveedahmed1, can you please share the link again? Thanks.
Sure, I just dropped you an email.
I am unable to replicate this
ng update @angular/cli --create-commits=true --force=true --next
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 18.0.0-next.3 to perform the update.
✔ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 54 dependencies.
Fetching dependency metadata from registry...
Package "@angular/pwa" has an incompatible peer dependency to "@angular/cli" (requires "^17.0.0", would install "18.0.0-next.3").
Package "@angular/material" has an incompatible peer dependency to "@angular/animations" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/cdk" has an incompatible peer dependency to "@angular/common" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/cdk" has an incompatible peer dependency to "@angular/core" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/material" has an incompatible peer dependency to "@angular/forms" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Package "@angular/material" has an incompatible peer dependency to "@angular/platform-browser" (requires "^17.0.0 || ^18.0.0" (extended), would install "18.0.0-next.6").
Updating package.json with dependency @angular-devkit/build-angular @ "18.0.0-next.3" (was "17.3.3")...
Updating package.json with dependency @angular/cli @ "18.0.0-next.3" (was "17.3.3")...
Updating package.json with dependency @angular/compiler-cli @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency typescript @ "5.4.5" (was "5.3.3")...
Updating package.json with dependency @angular/animations @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/common @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/compiler @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/core @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/forms @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/platform-browser @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/platform-server @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/router @ "18.0.0-next.6" (was "17.3.3")...
Updating package.json with dependency @angular/service-worker @ "18.0.0-next.6" (was "17.3.3")...
UPDATE package.json (3656 bytes)
✔ Packages successfully installed.
Committed migration step (19e8b1027): Angular CLI update for packages - @angular/cli@next.
** Optional migrations of package '@angular/cli' **
This package has 1 optional migration that can be executed.
Select the migrations that you'd like to run Migrate application projects using '@angular-devkit/build-angular:browser' and '@angular-devkit/build-angular:browser-esbuild' to use the '@angular-devkit/build-angular:application' builder.
▸ Migrate application projects using '@angular-devkit/build-angular:browser' and '@angular-devkit/build-angular:browser-esbuild' to use the '@angular-devkit/build-angular:application' builder.
Read more about this here: https://angular.dev/tools/cli/esbuild#using-the-application-builder
UPDATE tsconfig.json (747 bytes)
Migration completed (1 file modified).
No changes to commit after migration.
** Executing migrations of package '@angular/core' **
▸ Updates two-way bindings that have an invalid expression to use the longform expression instead.
Migration completed (No changes made).
No changes to commit after migration.
▸ Replace deprecated HTTP related modules with provider functions.
Migration completed (No changes made).
No changes to commit after migration.
That's strange, I tried it three times and ended up with this error.
I cloned the report, then run npm I -f and then run ng update command.
Have you tried it on Windows machine?
The issue doesn't seem to be caused by the Angular CLI, as the problem lies in the direct execution of 'git' commands which the CLI does during the ng update
process. This suggests a potential issue with Git or the system itself.
Do the following commands work for you when executed directly?
git ls-files -m -d -o --exclude-standard
git rev-parse HEAD
Thank you @alan-agius4 , I can confirm this indeed was an issue with git installation, I am now able to update the project using the ng update
command.
Thank you once again for time and looking into this.