Skip to content

Instantly share code, notes, and snippets.

@JamieMagee
Last active March 15, 2018 09:12
Show Gist options
  • Save JamieMagee/1e1d0ad8f42133464f9edb7c7a7db932 to your computer and use it in GitHub Desktop.
Save JamieMagee/1e1d0ad8f42133464f9edb7c7a7db932 to your computer and use it in GitHub Desktop.
Change git user automatically depending on directory
[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)>\"'
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