Loading...

Maintaining multiple identities with Git

Avatar
Author
Kirill Müller

When committing to a Git repository related to my consulting work, I must use my company e-mail address, kirill@cynkra.com. Not so much for my open-source work – for this, I prefer to use other e-mail addresses, like krlmlr+r@mailbox.org . (For example, Travis CI sends notification e-mails to the committer’s e-mail address, and I have set up filtering for that other address.)

Illustration
Photo by Carson Arias


Having to configure the e-mail address for each repository separately eventually gets annoying. Instead, I’d rather have all repos within a specific subdirectory use particular e-mail address.

All my Git repos live in ~/git. Subdirectories R and cynkra, contain R packages and repos related to consulting, respectively. To achieve the desired setup, I edit my ~/.gitconfig with the following entry:

[includeIf "gitdir:git/**"]
    path = git/.gitconfig

This ensures that all repos in the git directory use the git/.gitconfig file in addition to the main configuration. That file contains the following:

[includeIf "gitdir:R/**"]
    path = R/.gitconfig
[includeIf "gitdir:cynkra/**"]
    path = cynkra/.gitconfig

Finally, in ~/git/R/.gitconfig and ~/git/cynkra/.gitconfig, I configure the e-mail addresses I want to use for all repos pertaining to R and cynkra, respectively.

[user]
    email = ...

I verify the setup with git config -l | grep user. Indeed, cynkra repos use the cynkra e-mail address. Voilà!

The above approach requires a recent-ish version of git- version 2.14 or later should suffice. Read more about conditional includes.





More posts

EFS vs. NFS for RStudio on Kubernetes (AWS): Configuration and considerations

Patrick Schratz

Accessing Google's API via OAuth2

Patrick Schratz

seasonal 1.9: Accessing composite output

Christoph Sax

Google Season of Docs with R: useR! Information Board

Ben Ubah

Running old versions of TeXlive with tinytex

Kirill Müller

tsbox 0.3.1: extended functionality

Christoph Sax

Celebrating one-year anniversary as RStudio Full Service Certified Partner

Cosima Meyer, Patrick Schratz

Deprecating a pkgdown site served via GitHub Pages

Patrick Schratz, Kirill Müller

gfortran support for R on macOS

Patrick Schratz

Seasonal Adjustment of Multiple Series

Christoph Sax

Dynamic build matrix in GitHub Actions

Kirill Müller

Setting up a load-balanced Jitsi Meet instance

Patrick Schratz

DevOps Expert (f/m/d, 60-100%)

cynkra team

Maintaining multiple identities with Git

Kirill Müller

Relational data models in R

Angel D'az, Kirill Müller

tempdisagg: converting quarterly time series to daily

Christoph Sax

tsbox 0.2: supporting additional time series classes

Christoph Sax

DevOps System Engineer (40-60%)

cynkra team

Introducing dm: easy juggling of tables and relations

Balthasar Sager

tsbox 0.1: class-agnostic time series

Christoph Sax

Time series of the world, unite!

Christoph Sax

Done “Establishing DBI”!?

Kirill Müller


Other blogs

R-bloggers
Top