Legion
Legion

Reputation: 81

How to semi-manually control a file in git?

My problem is as such:
I have a repository for my dotfiles which includes the .gitconfig file. I store this repository on github and do not want to show my email/name there.

Simple solution:
use --assume-unchanged or --skip-worktree and manually add the file when it is modified.

Idea for better solution:
Use --assume-unchanged or --skip-worktree in conjunction with some pre-commit hook that tries to apply a patch to see if there were any modifications to the file except the lack of email in the indexed version. if there were then stop the commit.

Any ideas on how to implement such a thing ?

EDIT: the tricky part is of course to make git status show that the file is not modified in the working directory even though it has a username/password and the index doesn't but show it as modified if it has other changes.

Upvotes: 1

Views: 44

Answers (1)

klaustopher
klaustopher

Reputation: 6941

I know this is not a solution for the generic nature of your question.

But for your specific problem, there is an easy solution if you are using git > 1.7: You can store your username and email in a different file and include it in your global .gitconfig

See http://git-scm.com/docs/git-config#_includes

Upvotes: 2

Related Questions