2011-12-30 54 views
0

.gitignore文件看起來像這樣:如何忽略以〜在git結尾的文件?

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

但是,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~ 

什麼能日ereason是什麼?

+0

我認爲@ kan的回答正是你想要的,我有個人建議:在你的'.vimrc'中加入'set nobackup'。然後它不再生成'*。*〜'文件。 :) – Kjuly 2011-12-30 10:16:37

回答

5

modified表示您已經在repo中提交了該文件。您應該先將其刪除,然後再將其忽略。

0

很可能是因爲你有它的版本,它被添加到存儲庫(或索引)之前。