Repository is not clean. Please commit or stash any changes before updating In Angular 8

156,893

Solution 1

It's a bug in Angular 8

you can work around it by using:

ng update @angular/cli @angular/core --allow-dirty

Solution 2

I have tried using mention command for upgrading from angular 8 to angular 9, but was still getting the error.

Then i have tried same command with --force flag and it worked for me.

ng update @angular/cli @angular/core --allow-dirty --force

Solution 3

I've had the same issue. It's a common bug in Angular 8. Simply you can use dirty commands to bypass the repo check, such as (if u really need to bypass this, follow force commands)

ng update @angular/cli @angular/core --allow-dirty or
ng update @angular/cli @angular/core --allow-dirty --force

but, I didn't do that. I followed following steps...

first of all double check whether you are commited all the changes before the update.then keep a copy of the project to the same location and commit the copy also to the Git. then run following command from the original project directory

ng update @angular/core@8 @angular/cli@8

afterwards u can delete the copy. This worked for me! thank you!

Solution 4

I faced the same issue, which I resolved using the below command

git stash --include-untracked

Solution 5

Worked for me

sudo npm update @angular/cli @angular/core --allow-dirty --legacy-peer-deps
Share:
156,893

Related videos on Youtube

afeef
Author by

afeef

Updated on February 10, 2022

Comments

  • afeef
    afeef about 2 years

    Error

    Repository is not clean. Please commit or stash any changes before updating

    when i have updated from version 7 to Angular 8.

    Angular Guide for upgrade https://update.angular.io/#7.0:8.0

      D:\app-test> ng update @angular/cli @angular/core
                   npm cache verify
    

    Repository is not clean. Please commit or stash any changes before updating.

    Update Version

        PS D:\app-test> ng update
                    Using package manager: 'npm'
                    Collecting installed dependencies...
                    Found 58 dependencies.
                        We analyzed your package.json, there are some packages to update:
    
                          Name                               Version                  Command to update
                         --------------------------------------------------------------------------------
                          @angular/cdk                       7.2.2 -> 8.0.1           ng update @angular/cdk
                          @angular/core                      7.2.15 -> 8.0.1          ng update @angular/core
                          @angular/core                      7.2.2 -> 7.2.15          ng update @angular/core
                          @angular/material                  7.3.7 -> 8.0.1           ng update @angular/material
                          rxjs                               6.3.3 -> 6.5.2           ng update rxjs
    
    
                        There might be additional packages that are outdated.
                        Run "ng update --all" to try to update all at the same time.
    
                    PS D:\app-test> ng update @angular/cdk
                    Repository is not clean.  Please commit or stash any changes before updating.
    

    i have checked git was not installed in project.

    solution that worked

       git commit 
    

    After Googling i have This is happening After Angular 8.

    Bug

    https://github.com/angular/angular-cli/issues/14600

  • Shilpi Jaiswal
    Shilpi Jaiswal over 4 years
    this is not working .. giving error 'Repository is not clean. Update changes will be mixed with pre-existing changes. Using package manager: 'npm' Collecting installed dependencies... Found 0 dependencies. Package '@angular/cli' is not a dependency.'
  • Finn
    Finn over 4 years
    not working.., giving error 'Repository is no ...,' too.
  • Edric
    Edric over 3 years
    Note that the save option for git-stash is deprecated from Git 2.15/2.16 (Q1 2018) in favour of git stash push (or git stash).
  • Edric
    Edric over 3 years
    It's not a bug - it's an intentional feature which is applicable in the event that the CLI unintentionally updates a file that wasn't meant to be updated, potentially breaking your app.
  • qu1j0t3
    qu1j0t3 over 3 years
    @Edric It's a bug when it issues this message incorrectly, as it is doing for me (v8.2)
  • Geancarlo Murillo
    Geancarlo Murillo almost 3 years
    You save my day! Thank´s!
  • whitefang
    whitefang over 2 years
    This solution is valid for angular 12. Thanks
  • Yona Appletree
    Yona Appletree over 2 years
    I removed it from the answer, thanks @Edric.
  • jonathasborges1
    jonathasborges1 over 2 years
    thanks, worked for me!
  • Adam Norton
    Adam Norton almost 2 years
    None of the others worked for me but this one did!! May 2022
  • Adam Norton
    Adam Norton almost 2 years
    ng update @angular/cli @angular/core --allow-dirty gives me the error: Package '@angular/cli' is not a dependency.
  • chgav007
    chgav007 almost 2 years
    Also need to add --force