git如何忽略已经入库过的文件

1、忽略本地修改过的文件方法是:

在本地根目录下建立.gitignore文件,然后在文件中添加想要过滤文件名称。

#file .gitignore

abc

def

然后文件路径带有abc和def的文件都会被过滤掉。

2. 当文件在上次提交过,本次需要忽略掉不再修改时,上面的方式不适用,此次可以通过一下命令来解决:

git rm -r --cached file_path


关于--cached的参数说明如下:

--cached
   Use this option to unstage and remove paths only from the index.
   Working tree files, whether modified or not, will be left alone.