Seems that you opened vscode on the user directory, and one way to fix that is opening only your project folder. On the top menu you can try clicking on “File” -> “Open Folder…” and select your project folder.
Yes, just delete the .git folder, it’s not supposed to be there so get rid of it (at the minute you are trying to make git track every file in your root directory). Then reinitialise in the correct directory (and make sure you add node_modules to the .gitignore file).
If you delete it, you won’t have anything tracked, nothing will be “master”, this is what you want at the minute. The . git folder is just where the record of what’s being tracked lives, and atm it isn’t tracking anything you want, so deleting it is fine. If you initialise a git repo in the wrong folder, always just delete the .git folder and start again in the correct place
Yes, but if you’ve already started making changes and commits, won’t you lose that history?
For one project I accidentally initialized the git repo one directory too high and started making commits without realizing. It was the only thing in that top directory (/my-project/my-REAL-project) so it wasn’t really a problem. But it was annoying.
I discovered that you can actually move the .git folder and not lose any of your history. The first commit you make will be a big one of all the “renamed” files.
mv .git my-REAL-project
git add .
The “master” is the main/default branch of your project. It’s created when you initialized git with git init. It just means that those versions of the files are the default branch of your project. If you want to make major or experimental changes, you can create a new branch. After those changes are complete you can merge that branch back into master. Branching is kind of the point of git, so it’s good to learn eventually.
Yes, in certain circumstances you may want to do this, but ideally you don’t, you just delete. The issue is is that if you have committed changes, theres a very high likelihood that the git history is polluted by dint of making commits in a completely different directory. ie if it’s the root, then anything personal you do on your computer has the potential to be marked as a change, and it’s then ridiculously easy to accidentally commit completely unrelated stuff (often vast amounts of unrelated stuff if you’re not paying attention). And if that is the case, it often becomes very difficult to cherry pick out those erroneous commits.
As it is, yes, it may be fine, but that’s context sensitive, and nuking the entire thing is generally far, far easier and the correct thing to do.