如何忽略此文件“g4server.properties”

时间:2014-05-18 07:33:21

标签: git gitignore

➜  pms git:(v1) ✗ cat .gitignore 
/src/g4server.properties
/bin
.idea/
out/
pms.iml
➜  pms git:(v1) ✗ git status
# On branch v1
# 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:   .gitignore
#   modified:   src/g4server.properties
#
no changes added to commit (use "git add" and/or "git commit -a")

我在.gitignore中添加了/src/g4server.properties,但它似乎无效。如何忽略此/src/g4server.properties文件。

4 个答案:

答案 0 :(得分:3)

您可以选择两种方式:

从git存储库中完全删除src / g4server.properties,然后完全忽略它:

git rm --cached src/g4server.properties

并将其添加到.gitignore。

将src / g4server.properties保留在git存储库中,但忽略对此文件的未来更改

git update-index --assume-unchanged src/g4server.properties

如果您想再次开始跟踪更改,请运行以下命令:

git update-index --no-assume-unchanged src/g4server.properties

答案 1 :(得分:1)

那是因为你的文件在索引中。运行git rm --cached src/g4server.properties,它将被忽略。

答案 2 :(得分:1)

您无法忽略已由git跟踪的文件。

如果您不想跟踪该文件,可以使用git rm --cached将其删除。

答案 3 :(得分:0)

前导/指向文件系统的根目录。因此,将它作为本地存储库,如下所示:

src/g4server.properties

在.gitignore中。正如它在git status输出中显示的那样。

相关问题