Reputation: 31
Sorry if this is a newbie/weird question, I'm trying to figure out how to properly word it.
I'm having trouble getting git to only work in my current directory. What I mean is that when I run git add .
or git status
, I want git to add all the files in my current directory, or show the status of all the files in my current directory. For some reason, right now, git goes through ALL of the folders on my computer rather than just the ones in my current directory. I've used git many times before this and my old directories never had this issue and still work fine, but when I make a new directory this whole mess happens.
In the old directories it looks like this: C:\Users\Laptop\old-project>
. When I run git status
it correctly returns
On branch tuesday-react
Your branch is up to date with 'origin/tuesday-react'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/components/edit-listing/EditListingComponent.js
modified: src/components/home/HomeComponent.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/sonarlint/
which is what I want it to do.
Now my new project folder structure is like this: C:\Users\Laptop\new-project>
, but when I run git status
it returns this:
warning: could not open directory 'AppData/Local/Application Data/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permission denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: ../AppData/Local/Microsoft/Credentials/990192803892980309898N80283802FF
new file: ../AppData/Local/Packages/Microsoft.MicrosoftEdge_n7ht5rfjgt7yyt4op/AC/#!110/MicrosoftEdge/Cache/HGDTUYYU/config[1].json
new file: ../AppData/Local/Temp/lptmp/languages/af_ZA/af_ZA.xpm
new file: ../AppData/Local/Temp/lptmp/languages/af_ZA/lastpass.mo
new file: ../AppData/Local/Temp/lptmp/languages/ar_EG/ar_EG.xpm
new file: ../AppData/Local/Temp/lptmp/languages/ar_EG/lastpass.mo
new file: ../AppData/Local/Temp/lptmp/languages/ar_SA/ar_SA.xpm
new file: ../AppData/Local/Temp/lptmp/languages/ar_SA/lastpass.mo
.
.
.
.
which gives this gigantic error message thats thousands of lines long. None of these folders/directories are in my current directory and are somewhere in the Laptop
directory above the current one.
The internal structure and contents of both directories is exactly the same. I tried creating a new react app with a different name, updating git, restarting the computer, updating the IDE, and all of them have the same issue.
Can anyone help me with this or explain why it's doing this? Am I missing something?
Thanks in advance.
Upvotes: 2
Views: 1831
Reputation: 9481
This is because git works on the repository not in the current directory. In your. It finds the repository root by walking from your current directory to the root directory and looks for .git directory along the path.
As others have pointed out you probably have initialized a git repository somewhere in your home directory or in the root directory. To find where it is run the following command in your project directory
git rev-parse --show-toplevel
Then go the directory shown by the above command. If it shouldn't be a git repo, find a .git directory in there and delete it. This will delete the git repo there.
Repeat this process until you get your project directory to be top level git directory.
Upvotes: 6