4 ms·
I find it much easier to use direnv and set GIT_AUTHOR_EMAIL in each of ~/work/.envrc and ~/personal/.envrc No need to reconfigure every repo this way.
by 0xEFF 6y ago
I find it much easier to use direnv and set GIT_AUTHOR_EMAIL in each of ~/work/.envrc and ~/personal/.envrc No need to reconfigure every repo this way.
- cbcoutinho 6y agoI do the same. Also remember the following keyword if you use nested .envrc files: source_up If you don't use this in any nested envrc files, the settings don't carry over which means your git settings are not maintained. It is kind of an escape hatch as the parent files are not verified in the same way normal envrc files are, but I have found the trade off to be worth it
- augusto-moura 6y agoGit has conditional includes based on path[1]. My configuration is like: On ~/.gitconfig [user] name = personal email = personal@example.com [includeIF "gitdir:~/workspace/"] path = ~/work.gitconfig Then on ~/work.gitconfig [user] name = workname email = work@example.com [1] https://git-scm.com/docs/git-config#_conditional_includes https://git-scm.com/docs/git-config#_conditional_includes
- grenoire 6y agoWoah, this is neat!
- lilyball 6y agoJust a note of caution, when this feature was added tools based on libgit2 did not understand it. I just checked now, libgit2 eventually added support (though it took 5 months since I filed the ticket). But if you're using any tools that have a 3-year-old version of libgit2 they might not understand it.