Ignore configs with git

允我心安 提交于 2019-12-01 11:20:03

问题


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?


回答1:


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")



来源:https://stackoverflow.com/questions/28817040/ignore-configs-with-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!