忽略git配置 [英] Ignore configs with git

查看:109
本文介绍了忽略git配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我有配置文件有私人信息。我为Github提供了一些示例模板,但是我的工作副本中有实际的配置,所以我可以从中进行构建,但不希望它们可用于提交。

我尝试使用.gitignore,但模板已被追踪。我试过 git rm filename 但试图删除模板。我试过 git update-index --assume-unchanged filename git update-index --skip-worktree filename 但当使用 git status 时(以及在Github中用于Windows的提交文件),它们仍显示为已修改。



有没有什么办法可以忽略我已经做出的修改,而不需要从Github中删除模板?

解决方案

看起来像是,来自 Pro Git book


In my project I have config files that have private information. I committed some example templates to Github, but I have the actual configs in my working copy so I can build from it and I don't want them available to commit.

I tried using .gitignore, but the templates are already tracked. I tried git rm filename but that tries to delete the templates. I tried git update-index --assume-unchanged filename and git update-index --skip-worktree filename but they still show up as "modified" when using git status (and under Files to Commit in Github for Windows).

Is there any way to ignore changes that I've already made without removing the templates from Github?

解决方案

That looks like what a content filter driver (using .gitattributes declaration) is for:

  • the smudge part could replace the template content with the actual value (on checkout)
  • the clean part could restore the template (on commit)

(image from "Customizing Git - Git Attributes", from "Pro Git book")

这篇关于忽略git配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆