Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode "please clean your repository working tree before checkout"

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?

like image 631
hacking_mike Avatar asked Aug 13 '18 07:08

hacking_mike


People also ask

What is repository working tree?

Th Working Tree in Git is a directory (and its files and subdirectories) on your file system that is associated with a repository. It's full of the files you edit, where you add new files, and from which you remove unneeded files.


5 Answers

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:

  • git stash
  • git stash pop
like image 64
ddavidad Avatar answered Sep 29 '22 16:09

ddavidad


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

like image 35
Eimantas Avatar answered Oct 01 '22 16:10

Eimantas


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.

like image 28
VonC Avatar answered Oct 01 '22 16:10

VonC


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!

like image 25
Viktor Hardubej Avatar answered Oct 01 '22 16:10

Viktor Hardubej


for my case i simply had unstaged a file i went back and selected the file on my terminal and staged the file and i was free and ready to merge and commit

like image 25
Nelson Omondi Avatar answered Oct 03 '22 16:10

Nelson Omondi