在添加到.gitignore之后,git仍然显示文件被修改 [英] git still shows files as modified after adding to .gitignore
问题描述
我将此项添加到 .gitignore 文件中
.idea / *
但无论如何,状态是:
#修改:.gitignore
#修改:.idea / .generators
#修改:.idea / dovezu.iml
#修改:.idea / misc.xml
#modified:.idea / workspace.xml
我做错了什么?
i甚至将.idea / *添加到全局〜/ .gitignore_global
,但是git状态显示我:
#modified:.gitignore
#modified:.idea / .generators
#modified:.idea / dovezu.iml
#modified:.idea / misc.xml
#modified:.idea / workspace.xml
.gitignore
正在工作,但它仍然会跟踪这些文件,因为它们已经在索引中。 为了避免这种情况,您必须这样做: git rm -r --cached .idea /
当你提交 .idea /
目录时,将从你的git仓库中删除,以下提交将忽略 .idea /
目录。
PS:您可以使用 来自 i'm adding this to .gitignore file but anyway the status is: what am i doing wrong ?
i even added .idea/* to the global ~/.gitignore_global
but git status, anyway shows me:
Your To stop this you have to do : When you commit the PS: You could use Helpful quote from the
这篇关于在添加到.gitignore之后,git仍然显示文件被修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! .idea /
而不是 .idea / *
来忽略一个目录。您可以在 .gitignore 手册页上找到关于模式的更多信息。 a>。
git-rm
手册页
- cached
使用此选项可以仅从指数。
无论是否修改工作树文件,都将被单独保留。
.idea/*
# modified: .gitignore
# modified: .idea/.generators
# modified: .idea/dovezu.iml
# modified: .idea/misc.xml
# modified: .idea/workspace.xml
# modified: .gitignore
# modified: .idea/.generators
# modified: .idea/dovezu.iml
# modified: .idea/misc.xml
# modified: .idea/workspace.xml
.gitignore
is working, but it still tracks the files because they were already in the index. git rm -r --cached .idea/
.idea/
directory will be removed from your git repository and the following commits will ignore the .idea/
directory..idea/
instead of .idea/*
to ignore a directory. You can find more info about the patterns on the .gitignore man page.
git-rm
man page--cached
Use this option to unstage and remove paths only from the index.
Working tree files, whether modified or not, will be left alone.