问题
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