Skip to content

Instantly share code, notes, and snippets.

@zephraph
Last active March 11, 2018 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zephraph/ecbc7c1423b1d2eb14388ba118dfdc97 to your computer and use it in GitHub Desktop.
Save zephraph/ecbc7c1423b1d2eb14388ba118dfdc97 to your computer and use it in GitHub Desktop.
Git hook for automatically switching between work/oss accounts depending on the directory
#!/usr/bin/python
# This file should live at ~/.git/hooks
import os
from subprocess import call
if "git/work" in cwd:
print "Using work account"
call("git config user.name <Your name>", shell=True)
call("git config user.email <Your work email>", shell=True)
else:
print "Using oss account"
call("git config user.name <Your oss handle>", shell=True)
call("git config user.email <Your oss email>", shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment