'Cloned git repository in WSL2 keeps disappearing. Why is that?

I have cloned a git repository, from Gitlab, in WSL2, using the Ubuntu distribution, and when I start up the WSL2 on another time it is gone.

Can anybody tell me why this could happen?



Solution 1:[1]

There is an ongoing issue related to WSL2 and files disappearing

It can depend on your OS (W10? Which version? W11?) and if you have applied the latest Windows updates.

Check first %APPDATA%/Local/Packages/ if you see your files (before restarting WSL2).

And check, as in issue 6221, if rootfs is still visible. For instance: :\Users\<user>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
But, as NotTheDr01ds comments, that would be WSL1 only.

For WSL2, see microsoft/WSL issue 4699 "WSL 2 should automatically release disk space back to the host OS".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1