如何忽略git中的某些文件? [英] How to ignore certain files in git?

查看:178
本文介绍了如何忽略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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆