When you create a new repository with git init
, Git creates a hidden .git/
directory in the folder you are in. The existence of this .git/
directory means that the containing folder is recognised as a repository by Git. Git does not change anything else about the folder; all the relevant information is stored inside .git/
.
In your case, if you have a .git/
directory in your home folder, Git thinks the entire home folder is a repo, and tracks the changes in all the files and subfolders in your home folder - which is not what you want. You most probably want to delete the .git/
directory, after which Git will stop thinking that your home folder is a repo, and it will stop tracking all the contents of your home folder.
The .git/
directory also contains information about your repository history: the branches you have created, the commits, etc. If you have already committed something, by removing the .git/
directory you will lose the history of your commits. If you have created another branch and have some commits there, you will lose the commits on the other branch too.
However, if you have NOT committed anything yet, or have only worked on one branch, your files will NOT be deleted or changed - you can safely remove the .git/
directory.
When you want to create a new repository, you should first create a new folder, and run git init
inside that new folder - this will create the .git/
directory inside the folder, and Git will know that the folder contains your repo. Keep all your project files inside the folder, and Git will keep track of them.
By the way, if you want to tell Git to ignore (i.e. not track changes in) some specific files inside your repo - e.g. files containing secrets, built output files, or other files which you don't want to commit but keep in your folder for some reason - you can create a .gitignore
file and list such files there. There are also other options for ignoring files.