VSCode "please clean your repository working tree before checkout"

GitVisual Studio-Code

Git Problem Overview


In Visual Studio Code I made some changes which I do not want to commit en sync yet. However, after my holiday, I want to sync the files from the server (changes from my colleagues). So In Visual Studio Code I want to do a sync.

I get a message "Please clean your repository working tree before checkout"

What do I need to do to get the files of my colleagues without losing my own uncommitted changes?

Git Solutions


Solution 1 - Git

In my experience the best way to stash the changes is like so:

stash

sync the changes from your co-workers and afterward do stash-pop like so:

stash pop

You may also perform these actions in the terminal:

Solution 2 - Git

Create a temporary branch and commit the changes. Or if you don't want to create a temporary branch - stash the changes.

Solution 3 - Git

Not only should you stash, but VSCode 1.52 (Nov. 2020) will be even safer with:

> ## Git: Prompt to save files before stashing > > VS Code will now prompt you to save unsaved files whenever you attempt to stash changes.

Solution 4 - Git

in my case I had free working tree but VC code still say 'Please clean your repository working tree before checkout.'. I used git push -f origin to force push to origin. Maybe it will helps for someone!

Solution 5 - Git

what worked for was to just remove the unstaged changes from source control list that solved the problem.

Solution 6 - Git

What worked for me was to clean working tree to default state using the command below:

$ git clean -xfd

or

$ git clean -x -f -d

Before stashing

$ git stash

Solution 7 - Git

1、Discard changes; 2、Synchronize Changes

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionhacking_mikeView Question on Stackoverflow
Solution 1 - GitddavidadView Answer on Stackoverflow
Solution 2 - GitEimantasView Answer on Stackoverflow
Solution 3 - GitVonCView Answer on Stackoverflow
Solution 4 - GitViktor HardubejView Answer on Stackoverflow
Solution 5 - GitSalman HameedView Answer on Stackoverflow
Solution 6 - GitBlackPearlView Answer on Stackoverflow
Solution 7 - GitZhangYouzhiView Answer on Stackoverflow