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

发布于 2024-12-22 07:28:27 字数 440 浏览 1 评论 0原文

我想从git 存储库。

我怎样才能做到这一点?

目前我正在按以下方式执行此操作:

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

将文件一一删除。然后我承诺。

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

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

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

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

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

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:

.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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2024-12-29 07:28:27

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文