简体   繁体   English

如何忽略以git结尾的文件?

[英]How to ignore files ended with ~ in git?

My .gitignore file looks like that: 我的.gitignore文件如下所示:

> cat .gitignore
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
*~

But, git doesn't ignore the files ended with ~ : 但是,git不会忽略以~结尾的文件:

> git status
# On branch master
# 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:   app/views/jobs/_form.html.erb
#   modified:   app/views/jobs/_form.html.erb~
#   modified:   public/stylesheets/jobs_new_edit.css~

What could be th ereason for that? 这可能是什么原因?

modified means you have the file committed in the repo already. modified意味着您已经在存储库中提交了文件。 You should remove it first, then it will be ignored for addition. 您应该先将其删除,然后再将其忽略。

可能是因为您已对其进行版本控制,所以它之前已添加到存储库(或索引)中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM