簡體   English   中英

.gitignore 不會忽略文件

[英].gitignore does not ignore files

我有一個包含源代碼的文件夾。 它包含以下文件和文件夾:

/.git
/.vs
/bin
/obj
/src
/tests
.gitignore
docker-compose.dcproj
docker-compose.yml

文件.gitignore包括以下幾行:

/.vs
/bin
/obj

我預計.vsbinobj文件夾中的任何文件都不會包含在我的存儲庫中。 但是每次我更改我的存儲庫時,我都會看到文件夾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也不會被忽略

如何刪除 git 跟蹤的文件

# 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM