Multiple Git Repositories Multiple Emails

I’m using multiple git repositories for various work related and personal related projects.

Recently I was working with a repository at work and notice my personal email address in the commit log. Well, this wasn’t cool. I mean my personal email is awesome, but having it appear in work related commit log was… well not cool.

My .gitconfig had the following parameters set correctly for my personal Git repositories.

[user]
   name = Boogy Man
   email = boogyness@datagram.io

The command git config --list can be used to view a list of defined values for a Git config. Run this command from anywhere within the system.

If your command prompt resides in a cloned git repository, the command output from git config --list will include the output from the .gitconfig plus any local values in the .git/config file of that cloned repository.

Also, using anyone of the cat, less, more or favorite editor will achieve the same result.

Others 1 have run into the same, having multiple repositories – professional and personal. Thankfully, Git was updated 2 to resolve the matter as Orr Sella points out in his blog post.

The .gitconfig is the global config that resides outside of any repositories. Each git repository has it’s own config file within it.

/path/home_dir/.gitconfig
/path/home_dir/some_dir/git_clone_dir/.git/config

Replacing the email = boogyness@datagram.io stanza in the .gitconfig will influence Git to prompt for a name and email on a per repository basis. This of course will occur one time that repository and there after the user name and email will be recored within the repository’s config file.

first step: Updating the global git config first 3,

shell$ cd ~
shell$ git config --global user.useConfigOnly true
shell$ git config --global --unset-all user.email

second step: Then moving into the work repository the following is performed to set the work related email ,

shell$ cd /some_dir/git_clone_dir
shell$ git config user.email "serious@professional.com"
shell$ git config --list

The same will be done on any other local repository.

note: If just updating the git global .gitconfig is all you do, and skip setting the then the following git message will appear when you run git commit.

git commit

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: no email was given and auto-detection is disabled

 

 

 


  1. https://orrsella.com/2013/08/10/git-using-different-user-emails-for-different-repositories/
  2. https://github.com/git/git/commit/c37f9a1bc38cad56c9eca40014802e7cd822c21c
  3. The global config will display the user.name and user.email from the global .gitconfig in the output from git config --list. This is why we want to first remove the user.email from the global .gitconfig.

For Sale – Apple Computing

I’m selling several Apple related items. Please reach out to me if you are interested in acquiring any of these items.

Entertaining best offer so please make a fair judgment of the item’s worth to you.

Item List

  • MacBook 12-inch (1st Gen) [Available]
  • MacBook Pro Retinia 15-inch (3rd Gen) [sold]
  • MacBook Pro 15-inch (2nd Gen) [Available]
  • Apple Thunderbolt Display (27-inch) [Available]

Item Specs

Item History and Condition

Most of my computing devices have easily seen 12+ hours per-day of usage (give or take).

Except for the display, these items have traveled with me. They are in surprisingly good condition for the length of time and usage-duration.

  • MacBook 12-inch
    • Purchased: April 2015 for $1299.00 + AppleCare $249.00
    • Condition (keyboard/display): No defects, no blemishes, no scratches
    • Condition (exterior): Like new. Portfolio case that wraps around entire notebook body has been used for roughly 80% of the notebook’s life.
  • MacBook Pro Retinia 15-inch (3rd Gen)
    • Purchased: July 2012 for $3,499.00 + AppleCare $349.00
    • Condition (keyboard/display): No defects, minor wear, no scratches.
    • Condition (exterior): Minor scratches on bottom. No blemishes.
    • Comment: The built-in iSight camera no longer works.
  • MacBook Pro 15-inch (2nd Gen)
    • Purchased: July 2008 for $2,524.00
    • Condition (keyboard/display): Shows wear
    • Condition (exterior): some scratches
    • Comment: 1st battery replaced with OEM. 2nd battery replaced with aftermarket. Battery is dead, needs a battery. It currently operates from AC power.
  • Apple Thunderbolt Display (27-inch)
    • Purchased: July 2012 for $999.00
    • Condition: Like New
    • Defects/Blemishes: single line artifact about 2 pixels in width, dark yellow in color. Begins at top and ends at bottom of display. Located about 4-inches inward from right side of display.

Item Photographs

To Be Done (added)

Other Remarks

  • The items listed here still have their original box/packaging they came with. This may matter to some people so I thought I would mention it.
  • The computers will be “reset” and have the latest macOS installed.
  • Sold as-is – used equipment is unpredictable.  Please make sure you understand this before making me an offer 🙂
  • Why am I selling?  I’m upgrading my computing hardware after several years.