How to make a GIT repository become a common system folder again?

Good night, I'm learning GIT. In the beginning I created as a repository the folder of my desktop. That contains several files that have nothing to do with my projects. So I would like to know if you have how to undo this, I do not want to delete the my desktop folder. I just want it to be a common system folder again and not a GIT repository. How do I do that?

Author: user12864827, 2020-07-30

2 answers

When you run the command git init a new repository is created. This is nothing more than creating a hidden folder called .git. All information regarding git is contained in this directory.

On your desktop there is this folder. If you delete it, this directory will no longer be considered a Git repository. If you can't see it, it's because your operating system is set to hide hidden files and folders. You can uncheck this setting and delete manually.

One another option is to open the Windows Command prompt or Linux/Mac Terminal on the desktop and delete that folder there.

For reference, on Mac / Linux the command would be as follows:

rm -rf .git

For more information on how to view hidden files or a more detailed step-by-step, see this answer.

 3
Author: Naslausky, 2020-07-30 03:28:29
git restore --source=HEAD --staged --worktree -- aDirectory
# or, shorter
git restore -s@ -SW  -- aDirectory

With Git 2.23 (August 2019), you have the new command " git restore "

This would replace the index and working tree with the contents HEAD

Note that:

git checkout -- <path> 

Does not do a full reboot: it replaces the contents of the working tree with prepared content.

git checkout HEAD -- <path> 

Makes a definitive reset to a path, replacing the index and working tree with the commit version HEAD.

If you have files extras in the working tree that do not exist in the HEAD, a git checkout HEAD -- <path> will not remove them.

Note: with git checkout --overlay HEAD -- <path> (Git 2.22, Q1 2019), files that appear in the index and working tree but not in <tree-ish> are removed, to make them exactly match <tree-ish>.

 -1
Author: Eliseu B., 2020-07-30 03:10:42