[英].gitignore does not ignore files
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:文件.gitignore
包括以下几行:
/.vs
/bin
/obj
I excpect no file from .vs
, bin
and obj
folders will be included in my repository.我预计.vs
、 bin
和obj
文件夹中的任何文件都不会包含在我的存储库中。 But every time I change my repository I see two files from folder obj
.但是每次我更改我的存储库时,我都会看到文件夹obj
中的两个文件。 They are \obj\Docker\CachedComposeConfigFilePaths.cache
and \obj\Docker\MergedDockerCompose.cache
.它们是\obj\Docker\CachedComposeConfigFilePaths.cache
和\obj\Docker\MergedDockerCompose.cache
。 Why git does not ignore them and how do I fix it?为什么 git 不忽略它们,我该如何解决?
UPD output after git status
在git status
之后 UPD output
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")
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.另一种选择是这些文件已经被 git 跟踪。
Once you add a file to git it will not be ignored even if you add it to the .gitignore
将文件添加到 git 后,即使将其添加到.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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.