Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

git-multi-email

MIT License GitHub tag Build Status

Automatically changes git config user.email based on path

Working on projects for multiple organizations? This git hook changes your email address as necessary in the git config local to the current repository before commit.

asciicast

Getting started

Clone with git clone https://github.com/noahbass/git-multi-email.git. Then cd git-multi-email.

Ensure you have a core hooks directory (ex: ~/.git-config/hooks/). If not, use mkdir -p ~/.git-config/hooks/ to create it and use git config --global core.hooksPath ~/.git-config/hooks/ to configure that directory as your hooks path.

git config --global core.hooksPath ~/.git-config/hooks/

Then, use these commands to copy the hook to the global hooks folder:

  • cp ./post-commit ~/.git-config/hooks/post-commit
  • chmod a+x ~/.git-config/hooks/post-commit
  • mkdir ~/.git-config/hooks/vendor/
  • cp ./vendor/ini-parser.sh ~/.git-config/hooks/vendor/ini-parser.sh

Next, configure your ~/.gitconfig file...

Configuration

Update your ~/.gitconfig file to include a new section called [emails]. Example configuration file:

...
[user]
	name = Noah Bass
	email = noah@noahbass.com
[emails]
	astronomerio = noah@astronomer.io
	acmatuc = noah@acmatuc.org

So now, any commit made in a repo within a folder named astronomerio will use noah@astronomer.io as the email address. Similarly, any commit made in a repo within a folder named acmatuc will use noah@acmatuc.org as the email address. Otherwise, commits will use the default noah@noahbass.com as the email address.

(Remember that the .gitconfig file follows the INI format)

Notes

  • Requires Git v2.9.0 or later
  • Not tested on Windows

Hacking on git-multi-email

TODO

Tests

Run tests with Docker! Use docker build -t git-multi-email-test . --no-cache --rm to build the image, then docker run --rm git-multi-email-test to run the tests.

Or, you can choose to run the tests without Docker by using sh ./test/setup.sh, then sh ./test/test.sh.

Note: tests running on Travis CI use Docker.

License

MIT License

About

Automatically changes `git config user.email` based on path 🚀

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.