Last active
October 1, 2015 05:28
-
-
Save mechanical-snail/1930235 to your computer and use it in GitHub Desktop.
gitconfig for managing multiple git identities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
; No default user, lest you start a project as the wrong user. | |
; You have to specify your identity per-repository, using init-xxx or setuser-xxx. | |
; @@@@@ TODO: Should actually give an error when trying to commit before specifying an identity. | |
name = "@@@No user configured@@@" | |
email = "@@@No user configured@@@" | |
[alias] | |
;;;;;; init and user control | |
; Creates an empty repository with root commit | |
; "git remote add origin .." is to make relative paths in submodules work; see http://stackoverflow.com/questions/1974181/ | |
z--init-root-commit = !git init && git commit -m 'root commit' --author 'nobody <nobody@localhost>' --allow-empty && git remote add origin .. | |
init-u0 = !git z--init-root-commit && git setuser-u0 | |
init-u1 = !git z--init-root-commit && git setuser-u1 | |
; sets user info for the current repository. Should be run immediately after init. Author info is not changed in existing commits. | |
setuser-u0 = !git config user.name 'Username 0' && git config user.email '[email protected]' && git whoami | |
setuser-u1 = !git config user.name 'Username 1' && git config user.email '[email protected]' && git whoami | |
;whoami = config --get-regexp 'user\\..*' | |
whoami = !bash -c 'echo \"$(git config --get user.name) <$(git config --get user.email)>\"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
email = "(none)" would do the work of causing an error in commit if no per-local identity is configured.