Last active
March 15, 2018 09:12
-
-
Save JamieMagee/1e1d0ad8f42133464f9edb7c7a7db932 to your computer and use it in GitHub Desktop.
Change git user automatically depending on directory
This file contains 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
[alias] | |
# Manage git user identities | |
work = "!f() { git config --local user.email \"[email protected]\"; }; f" | |
personal = "!f() { git config --local user.email \"[email protected]\"; }; f" | |
whoami = !sh -c 'echo \"$(git config --get user.name) <$(git config --get user.email)>\"' |
This file contains 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
function __change_git_user -v PWD -d "Change git user depending on directory" | |
status --is-command-substitution; and return | |
if git rev-parse --is-inside-work-tree > /dev/null ^ /dev/null | |
switch $PWD | |
case "*work*" | |
git work | |
case "*" | |
git personal | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment