Skip to content

Instantly share code, notes, and snippets.

@zephraph zephraph/pre-commit
Last active Mar 11, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.