I just started a new job where git is being used and since I had accumulated some stuff in mit
.gitconfig, I wanted it to be on my work computer too. I use a git repository for all my dotfiles, which I then clone on the machine and symlink files like
.vimrc to the home directory. This means if I add something to those files at work and want to use the configuration at home too I just need to commit, push and pull the changes at home. Well, this works pretty good until you realise that there are some config entries you want to be different in the two environments. Git’s
user.email is obviously such a case.
Git does not allow you to to include other configuration files in your
.gitconfig but you can use the environment variable
user.email. What I have done is to add the following to my
.bashrc (which is also in the dotfiles repo):
This loads a host-specific bash file (if it exists). In this file you’ll stick your email address like this:
(Obviously this file needs to be recreated on each host and can’t be shared across computers through the dotfile repository.) Now you can safely share your
.gitconfig between the two computers without having to worry about the email settings.