忽略 git 中的本地配置文件
Rails 应用程序中有一些本地文件(属于我们存储库的一部分),我希望 git 忽略它们。基本上,我希望 git 忽略我对 config/environments 目录和 config/application.rb 文件中的任何内容所做的所有更改。我不想使用 .gitignore,因为我不希望其他在代码库上工作的人的配置被 git 忽略。基本上,我正在做大量修改配置文件的测试,有时我的配置更改会被签入 github,这至少会令人尴尬,最坏的情况会导致生产环境出现问题。
这里最好的方法是什么?
There are some local files (that are part of our repository) in a rails app that I would like git to ignore. Basically, I'd like git to ignore all changes I make to anything in the config/environments directory and to the config/application.rb file. I don't want to use .gitignore because I don't want OTHER people working on the code base to have their configurations ignored by git. Basically I'm doing a lot of testing that modifies the config files and sometimes my config changes are checked into a github which at a minimum is embarassing and at worst causes issues with the production environment.
What's the best approach here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以设置全局 .gitignore。
尽管如此,它仍然会看到存储库中已经的文件的更改。以下是解决此问题的方法 。你也许可以用它制作一个 bash 宏。
You can set up a global .gitignore.
Although, it will still see changes in files that already are in the repository. Here's how you work around this. You can probably make a bash macro out of it.
您可以执行 git update-index --assume-unchanged config/application.rb ,并且 git 不会注意到您对该文件的本地副本所做的任何更改,除非您显式使用 git add< /代码>。
我的理解是 .gitignore 和朋友不会改变已经放入存储库的文件的处理方式,只会改变未跟踪的文件是否作为候选文件出现。
You can do
git update-index --assume-unchanged config/application.rb
and git will not notice any changes you make to the local copy of that file unless you explicitly usegit add
.My understanding is that
.gitignore
and friends won't change how files that are already put into the repository are handled, only whether untracked files are presented as candidates.您可以定义一个 全局 .gitignore ,它是您的计算机特定的,而不是签入项目存储库。
You can define a global .gitignore that would be your machine specific, not checked into project repository.
检查 .gitignore 文件。如果不只是创建一个文件 .gitignore 并提及您要忽略的文件列表,如下所示 config/database.yml
check for the .gitignore file.If not just create a file .gitignore and mention the list of files you want to ignore like this config/database.yml