简体   繁体   中英

How to ignore files ended with ~ in git?

My .gitignore file looks like that:

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

But, git doesn't ignore the files ended with ~ :

> 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. You should remove it first, then it will be ignored for addition.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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