0

The .git folder that I have created into my desktop contains the data of around 64GB so i think to delete that folder to free up some space in my system Now what to do to regain that data again ? Which git command should I use to restore the data ?

I tried to free up the space by deleting the .git folder which contain 64GB of data. But almost whole data of my desktop was deleted .

  • 2
    1: Git is not a backup system, and using it as if it were one is unwise. 2: Removing the `.git` folder using the system's "remove a folder" utility does not remove the files in the working tree, but *does* make it so that *Git* cannot help you get the Git folder back. You'll need to use some non-Git program to get them back. – torek Oct 26 '22 at 06:12
  • We won't have enough information to help you. Something else is going on. Git is just a version control software. Removing the .git folder from a repository only removes the versioning information. It does not remove any of the working files. It would seem as though you have deleted them by some other means. – Nilpo Oct 27 '22 at 22:48

1 Answers1

0

The .git directory contains all your repository data. I.e., it has all the commits and version history. When you have access to the .git directory, you can restore the working directory (your actual data) using the git restore command. Move the .git directory into e.g. C:\mygit and run git restore C:\mygit.

As noted by @torek, it's unwise to use git as a general backup system. Git is not a backup or cloud file sync software. Don't put the contents of your Desktop directory into version control unless you have a strong need for it.

bahrep
  • 29,961
  • 12
  • 103
  • 150