سؤال

I store dotfiles in a git repo, however I do have different set of local changes for .gitconfig (which is under version control) - it may be different environment (autocrlf true) or different username.

Right now every time I checkout the repo I go for:

git stash save && git pull && git stash apply

Which doesn't seem like a best practice to me. How should I go about having different set of local changes on different machines? What's the cleanest and the most explicit way? Or am I even addressing the wrong problem to begin with?

هل كانت مفيدة؟

المحلول

you might want to split out host-specific settings into a non-tracked file. the include-statement is available in git>=1.7.10.

something like following could do the trick:

 [include]
 path = ~/.gitconfig.local

i guess, what would be really nifty, would be something like:

 [include]
 path = ~/.gitconfig.${HOSTNAME}.local

and then track both .gitconfig.foo.local and .gitconfig.bar.local in the repository, but the former get's used on host foo and the latter on host bar. unfortunately variable-expansion is currently not supported.


alternatively you might set your GIT_CONFIG environment-variable to a system-specific value in your .bash_profile/.profile/.bashrc


finally, git uses ${prefix}/etc/gitconfig for host-wide configuration, probably you can use this for host-wide configuration.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top