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

Mis*_*hko 0 git gitignore

我的.gitignore文件看起来像这样:

> cat .gitignore
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
*~
Run Code Online (Sandbox Code Playgroud)

但是,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~
Run Code Online (Sandbox Code Playgroud)

这可能是什么原因?

kan*_*kan 5

modified意味着你已经在repo中提交了文件.您应该首先删除它,然后将被忽略添加.