如何忽略git中的某些文件? [英] How to ignore certain files in git?
问题描述
我有一个文件 Hello.java
的存储库。当我编译它时,会生成一个额外的 Hello.class
文件。
我为 Hello.class
在 .gitignore
文件中。然而,该文件似乎仍然被跟踪。
我想知道如何让git忽略 Hello.class
。
问题是, .gitignore
之前跟踪(由 git add
)。运行 git reset name_of_file
来取消保存文件并保留它。如果你还想从存储库中删除给定的文件(推后),使用 git rm --cached name_of_file
。
I have a repository with a file Hello.java
. When I compile it an additional Hello.class
file is generated.
I created an entry for Hello.class
in a .gitignore
file. However the file still appears to be tracked.
I want to know how to make git ignore Hello.class
.
The problem is that .gitignore
ignores just files that weren't tracked before (by git add
). Run git reset name_of_file
to unstage the file and keep it. In case you want to also remove given file from the repository (after pushing), use git rm --cached name_of_file
.
这篇关于如何忽略git中的某些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!