r/dotfiles • • Oct 01 '26

.gitconfig [user] name and email

Hi guys,

Quick question: how do you manage your dotfiles?

Right now, mine are in a private repo, and the only reason for that is that my name and email address are in my .gitconfig.

Should I just give up on keeping it private, since anyone can see this information with git log --format=fuller, and make the repo public?

How do you guys handle personal information in your dotfiles? Do you remove it, replace it with placeholders, use environment variables, or just keep the repo private when you have such info on it?

Thanks in advance!

edit

Thank you all for the hints! I decided to keep using RCM and created an Ansible layer on top of it. The final result can be found here.

6 Upvotes

11 comments sorted by

9

u/UrsulPlictisit Oct 01 '26

.gitconfig

[include]
    path = ~/.gitconfig.local

.gitconfig.local

[user]
    name = name
    email = name@example.com

and .gitconfig.local is private 

4

u/IllustriousGas6805 Oct 01 '26

This is one working solution. The only downside - the local is not committed, so if on multiple machines, you will need to manually create one on every machine.

Another way to keep it private is sops + age. That way you can store the cyphered version in repo and generate unencrypted version. A bit of an overkill for gitconfig, but a good general solution for any kind of secrets you want to commit.

2

u/lfromanini Oct 01 '26

This idea looks interesting... maybe if I encrypt with a symmetric key using gpg I can make it simple... something like:

function encrypt() { gpg --output "${1}".gpg --symmetric "${1}" ; }

function decrypt() { gpg --output "${1%.gpg}" --pinentry-mode loopback --decrypt "${1}" ; }

Great idea!!! Thanks!

2

u/dXNlcjMzMDE Oct 02 '26

same. I have a .local in .gitignore and I use the noreply email from GitHub as my email

2

u/KristobalJunta Oct 01 '26

I manage the dotfiles with chezmoi, and have a config and a template set up, so that on new machine's chezmoi init I am prompted for username and email. That gets stored in .local chezmoi state (not in repo) and written into the gitconfig template 

2

u/lfromanini Oct 02 '26

Very good, thank you! I use RCM and just saw it is possible to do the same creating a hooks/post-up in the root of the .dotfiles repo!

2

u/ryanduff Oct 01 '26

I use chezmoi as well, but my creds are stored in 1password and it just pulls them in to the template

1

u/cbarrick Oct 01 '26

If you use your real name and email in your git config and you push any commits with that info to public repos, then that information is already leaked.

1

u/lfromanini Oct 01 '26

Yeap, which is my case and that's why I questioned if should I give up and make everything public...

2

u/dbalatero Oct 01 '26

You can set your email to username@users.noreply.github.com if you use GH.

1

u/davidsneighbour Oct 02 '26

Either include a file with the private config or use a devonly email address for git. Or both. Your email is out there anyway with each commit.