[英].gitignore does not ignore files
我有一個包含源代碼的文件夾。 它包含以下文件和文件夾:
/.git
/.vs
/bin
/obj
/src
/tests
.gitignore
docker-compose.dcproj
docker-compose.yml
文件.gitignore
包括以下幾行:
/.vs
/bin
/obj
我預計.vs
、 bin
和obj
文件夾中的任何文件都不會包含在我的存儲庫中。 但是每次我更改我的存儲庫時,我都會看到文件夾obj
中的兩個文件。 它們是\obj\Docker\CachedComposeConfigFilePaths.cache
和\obj\Docker\MergedDockerCompose.cache
。 為什么 git 不忽略它們,我該如何解決?
在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")
添加以下內容:(你不需要它們,但它會工作)它可以更有效地編寫,但為了簡單起見,你想忽略文件夾的內容
.git/**
**/.vs/**
**/bin/**
**/obj/**
您想忽略文件夾中的文件
另一種選擇是這些文件已經被 git 跟蹤。
將文件添加到 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.