Reputation: 1111
I have a folder with source code. It contains the following files and folders:
/.git
/.vs
/bin
/obj
/src
/tests
.gitignore
docker-compose.dcproj
docker-compose.yml
File .gitignore
includes the follwing lines:
/.vs
/bin
/obj
I excpect no file from .vs
, bin
and obj
folders will be included in my repository. But every time I change my repository I see two files from folder obj
. They are \obj\Docker\CachedComposeConfigFilePaths.cache
and \obj\Docker\MergedDockerCompose.cache
. Why git does not ignore them and how do I fix it?
UPD output after git status
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: obj/Docker/CachedComposeConfigFilePaths.cache
modified: obj/Docker/MergedDockerCompose.cache
modified: // another files
Untracked files:
(use "git add <file>..." to include in what will be committed)
//some files
no changes added to commit (use "git add" and/or "git commit -a")
Upvotes: 2
Views: 2732
Reputation: 263
I use this command
git rm -rf --cached .
git add .
git commit -m "Update .gitignore"
please try to fix it. hope to help u
Upvotes: 0
Reputation: 142214
Add the following: (you don't need them all but it will work) It can be written more efficiently but to make it simple you want to ignore the content of the folders
.git/**
**/.vs/**
**/bin/**
**/obj/**
You want to ignore the files in the folder
Another option is that those files are already tracked by git.
Once you add a file to git it will not be ignored even if you add it to the .gitignore
# Remove any file you have already committed and you wish to ignore
git rm -rf --cached .vs/*
# now add the ignored pattern to your .gitignore file
git add .
# commit and push the removal of the ignored files.
git commit -m "Removed idea files"
#Push the changes
git push
Upvotes: 6