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

Asked

Viewed 464 times

0

Good evening, I’m learning GIT. At first I created my desktop folder as a repository. Which contains several files that have nothing to do with my projects. So I was wondering if you have a way to undo that, I don’t want to delete my desktop folder. I just want it to go back to being a common system folder and not a GIT repository. How do I do this?

2 answers

3


When you turn the remote git init a new repository is created. This is nothing more than creating a folder occult calling for .git. All information related to git is contained in this directory.

In your desktop there is this folder. If you delete it, this directory will no longer be considered a Git repository. If you cannot see it, it is because your operating system is with hidden file and hidden folders setting. You can uncheck this setting and delete manually.

One another option is to open Windows command prompt or Linux/Mac Terminal on 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 (in English).

-1

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 the work tree with the content HEAD

Note that:

git checkout -- <path> 

does not perform a full reset: replaces the contents of the working tree with the prepared content.

git checkout HEAD -- <path> 

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

If you have extra files in the work tree that do not exist in HEAD, a git checkout HEAD -- <path> shall not remove them.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.