如何从git存储库中删除或忽略.rb~文件?

时间:2022-06-01 21:58:33

I want to remove/igonre/hide whichever is better .rb~ and .# files such as .#admin.rb.1.2 from the git repository.

我想从git存储库中删除/ igonre / hide更好的.rb~和。#文件,例如。#admin.rb.1.2。

How I can do this?

我怎么能这样做?

Currently I am doing it in following way:

目前我正在以下列方式进行:

  git rm -r  "/app/models/.#admin.rb.1.2"

which removes the files one by one. Then I commit.

它逐个删除文件。然后我承诺。

I also created a .gitignore file with the following values which I found for Rails:

我还创建了一个.gitignore文件,其中包含我为Rails找到的以下值:

.bundle
db/*.sqlite3*
log/*.log
*.log
/tmp/
doc/
*.swp
*~
.project
.DS_Store 

But it is not ignoring the files which are already present in the directory.

但它并没有忽略目录中已存在的文件。

Will this file ignore .rb~ backup files? What should I do so that it will remove all the files which match the expression written in .gitignore files?

这个文件会忽略.rb~备份文件吗?我应该怎么做才能删除与.gitignore文件中写的表达式匹配的所有文件?

1 个解决方案

#1


1  

Files which are already in git will not be ignored anymore. First you have to remove them all and then the .gitignore file is going to ignore the new ones.

已经在git中的文件将不再被忽略。首先,您必须将它们全部删除,然后.gitignore文件将忽略新的文件。

#1


1  

Files which are already in git will not be ignored anymore. First you have to remove them all and then the .gitignore file is going to ignore the new ones.

已经在git中的文件将不再被忽略。首先,您必须将它们全部删除,然后.gitignore文件将忽略新的文件。