I'm having trouble using .gitignore
with my .vscode
folder in my repository.
I added a rule in my .gitignore
to ignore my entire .vscode/
folder:
# Visual Studio Code #
.vscode/*
.vscode/settings.json
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history.vscode/settings.json
Despite this, .vscode
is still being tracked by my local git repository. I've tried a variety of different solutions including using git filter-branch
to remove this folder from my git history and git rm --cached .vscode
to clear my cache and re-commit my changes, but none of these solutions prevents the .vscode folder from being tracked by git.
When I run git status
I keep getting this result:
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vscode/
nothing added to commit but untracked files present (use "git add" to track)
So far, I've worked around this by manually excluding this folder when I git add
my changes.
Why is .vscode/
still being shown as untracked? If I were to git add .
and git commit
this, it would add this folder to my git history and eventually to my remote repository when I git push
. I don't want this behavior to occur.
Choose Tools > Options > Source Control > Perforce > Ignoring Files. Set your 'Ignore List' preference, including the 'Ignore List' file name.
Had similar problem, turned out the files were added to my cache. Clearing it with below command worked.
git rm --cached .vscode/settings.json
Reference to the issue on github where I found the solution.
Maybe try this in your .gitignore. This should ignore the entire .vscode directory, no matter where it is located.
**/.vscode/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With