One’s configuration evolves over years and is slowly refined over time. Versioning it in git eases management and backup of this important work. To have an homogenous setup despite variations between work and personnal computer, I use chezmoi with templates.

For instance, in the git configuration, I put the following in my .gitconfig chezmoi template:

[user]
	email = {{ .email }}

and it gets rendered to this:

[user]
	email = me@my.home

on my personal computer and this

[user]
	email = me@my.work

on my work computer.

Chezmoi has lot of other features, like support for encryption. Even if you already use a configuration management system, you should check out how it compares!