How to ignore files ended with ~ in git?

本秂侑毒 提交于 2019-12-25 03:35:17

问题


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?


回答1:


modified means you have the file committed in the repo already. You should remove it first, then it will be ignored for addition.




回答2:


Probably because you have it versioned, it was added to the repository (or index) before.



来源:https://stackoverflow.com/questions/8678325/how-to-ignore-files-ended-with-in-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!