Github 和 .gitignore 中的非忽略文件

发布于 2024-09-09 08:31:29 字数 1076 浏览 1 评论 0原文

我需要在 .gitignore 文件中编辑一个文件。

我编辑了 .gitignore 并提交了它,但我的文件仍然无法提交。

我删除了该文件,然后读取了它,一旦它具有相同的名称,它仍然无法提交。

我尝试了 -f,然后将文件的空版本添加到我的存储库中。最糟糕的是,如果我进行部署,此时它会破坏我的整个应用程序。

更新:

我要添加的文件是:

 public/javascripts/ckeditor/config.js

我的 .gitignore 文件说:

 public/stylesheets/*.css
 *.swp
 *.pid
 .idea
 config/database.yml
 log/*.log
 db/*.sqlite3
 tmp/**/*
 doc/api
 doc/app
 doc/plugins
 public/system/*
 coverage.data
 coverage/*
 .DS_STORE
 .DS_Store
 solr/data/**/*
 solr/pids/**/*
 config/initializers/mail_delivery_override.rb

Git 状态揭示了这一点:

  # On branch testing
  # Changed but not updated:
  #   (use "git add <file>..." to update what will be committed)
  #   (use "git checkout -- <file>..." to discard changes in working directory)
  #
  # modified:   public/javascripts/ckcustom.js
  #
  no changes added to commit (use "git add" and/or "git commit -a")

ckcustom.js 是来自 ckeditor 套件的编译文件,是由其他更改生成的。但我不能只编辑该文件,我必须编辑其内部工作原理。

I had a file I needed to edit in my .gitignore file.

I edited .gitignore, committed it, and still my file was unavailable to commit.

I deleted the file, readded it, and once it has the same name, its still unavailable to commit.

I tried -f, which then added an empty version of the file to my repository. And the worst apart about that is that if I deployed, it would break my entire application at this point.

Update:

The file I want to add is :

 public/javascripts/ckeditor/config.js

my .gitignore file says :

 public/stylesheets/*.css
 *.swp
 *.pid
 .idea
 config/database.yml
 log/*.log
 db/*.sqlite3
 tmp/**/*
 doc/api
 doc/app
 doc/plugins
 public/system/*
 coverage.data
 coverage/*
 .DS_STORE
 .DS_Store
 solr/data/**/*
 solr/pids/**/*
 config/initializers/mail_delivery_override.rb

Git status reveals this :

  # On branch testing
  # Changed but not updated:
  #   (use "git add <file>..." to update what will be committed)
  #   (use "git checkout -- <file>..." to discard changes in working directory)
  #
  # modified:   public/javascripts/ckcustom.js
  #
  no changes added to commit (use "git add" and/or "git commit -a")

That ckcustom.js is a compiled file form the ckeditor suite that is made by other changes. But I can't just edit that file, I had to edit its inner workings.

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

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

发布评论

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

评论(2

墨落成白 2024-09-16 08:31:29

下次尝试:

git add -f path/to/ignore_file

Next time try:

git add -f path/to/ignore_file
旧城烟雨 2024-09-16 08:31:29

好吧,我很确定这有效,但这真的很奇怪!差点就因为这个而失去了一些辫子。

首先,我手动登录到我的服务器,删除了 git 制作的蹩脚文件。重新创建它,复制并粘贴我的文件,然后让我的服务器重新上线。

然后我访问 github.com 并直接从在线 API 手动打开、编辑和提交该文件。

我阅读了 .gitignore 文件和 ckcustom.js 文件,问题似乎已解决。

哎呀!

Ok I'm pretty sure this worked, and this was really strange! Almost lost some dreadlocks over this one.

To begin, I logged in manually into my server, deleted the crappy file git had made. Recreated it, copied and pasted my file back in, and got my server back online.

Then I went to github.com and manually opened, edited, and committed the file right from the online API.

I readded the .gitignore file, and the ckcustom.js file, and the problem seems to be fixed.

Sheesh!

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