I am very new to git and github and somehow I have a ton of program files in my Unstaged Changes section of Git GUI. I have no idea what I did for them to be there and I'm trying to find out how to get rid of them and if it's safe to do so.
-
1You're using `git` incorrectly - it looks like your own home-directory is a git repo. You should not be doing that. – Dai Feb 12 '21 at 03:06
-
Out of curiosity, are you previously (or currently) an SVN or TFS user? What OS are you using? – Dai Feb 12 '21 at 03:08
-
Years ago I had tortoise svn and I'm on Windows 10 now. also have a git repository in under users\my name file. I read somewhere I should delete it, but I wasn't sure. that's why I'm on here. thanks – markanthony Feb 12 '21 at 03:10
-
1**Don't delete it** (in case there's something valuable inside of it), just move it elsewhere, perhaps to a folder on your desktop so it won't capture the rest of your files. – Dai Feb 12 '21 at 03:11
-
Same as https://stackoverflow.com/questions/62244042/how-to-remove-all-local-files-that-were-accidentally-added-to-the-git-system except on windows. – matt Feb 12 '21 at 03:41
-
So...move the .git folder to the trash and move on??? – markanthony Feb 12 '21 at 03:54
-
That's what I would do. It's a dangerous situation. – matt Feb 12 '21 at 04:55
-
I disabled git from vscode and since I just started using it I won't miss it. Would uninstalling git make a difference? Thanks – markanthony Feb 12 '21 at 05:05
1 Answers
I am very new to git and github
Yes, I can tell.
and somehow I have a ton of program files in my Unstaged Changes section of Git GUI. I have no idea what I did for them to be there
What's happened is you have somehow set-up a git
repo in the root of your home directory (~
on Linux, aka C:\Users\{you}
or %HOMEPATH%
on Windows, or /Users/{you}
on macOS). This is a bad thing and you should not have done this.
- When a directory in the filesystem is a used for a git repo it contains a subdirectory named
.git
.- This
.git
directory contains only that git repo's object database, indexes, and all the gubbins. (This actual contents of the.git
directory should be left alone, otherwise you risk corrupting it). - The files that are under source-control are all descendants of the ancestor directory of the
.git
directory.- That is, all siblings of the
.git
directory are considered part of the git repo (unless explicitly filtered out by your.gitignore
file).- In your case, that includes your
.VirtualBox
configuration directory (and virtual disk images, I believe), yourAppData
folder, yourMy Music
folder, and more. - I hope you can understand why this is a bad thing.
- In your case, that includes your
- That is, all siblings of the
- This
and I'm trying to find out how to get rid of them and if it's safe to do so.
Seeming as those files are your user account's files (e.g. your downloads, your VirtualBox images, your personal documents, your tax returns, your IDE configuration, scans of your birth certifate, etc you probably shouldn't "get rid" of them.
Look for a folder named .git
in the root of your home directory (it may be hidden by Windows Explorer or whatever shell you're using) and move it (don't copy it, don't delete it) to another directory on your filesystem that is not an ancestor of anything important - then you can make more sense of it.
Try this (assuming you're on Windows):
cd %HOMEPATH%
cd Desktop
mkdir WeirdGitRepo
cd ..
move ".git" "Desktop\WeirdGitRepo\.git"
cd "Desktop\WeirdGitRepo"
git status

- 141,631
- 28
- 261
- 374
-
I have c:\Users\MyName\.git...so I have to go into the command line and move this file to somewhere like my desktop. Thanks – markanthony Feb 12 '21 at 03:23