Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:30:06+00:00 2026-06-11T00:30:06+00:00

I have separate email addresses that I use for work projects vs open source

  • 0

I have separate email addresses that I use for work projects vs open source projects, and I want to ensure that I use the correct one for each type of project.

Obviously the solution is to set the repository specific configuration appropriately, unfortunately I keep forgetting to set it until I’m a few commits in and so am using the global user.email config, which is fine if that matches up with what I’m working on, but not so fine otherwise.

If the user.email isn’t set anywhere git just crams the local username and host together to make one up (not so awesome for a desktop machine); I’d like it to just block the commit. I don’t think hooks will work, since I want this to happen for new & cloned repos – if I’m manually copying a hook into a repo, I should probably set the config instead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:30:07+00:00Added an answer on June 11, 2026 at 12:30 am

    New Update (February 2016, for git 2.8)

    git 2.8 (March 2016) will add a new solution:

    See commit 4d5c295 (06 Feb 2016) by Dan Aloni (da-x).
    Helped-by: Eric Sunshine (sunshineco).
    See commit 59f9295 (04 Feb 2016) by Jeff King (peff).
    Helped-by: Eric Sunshine (sunshineco).
    (Merged by Junio C Hamano — gitster — in commit c37f9a1, 17 Feb 2016)

    ident: add user.useConfigOnly boolean for when ident shouldn’t be guessed

    It used to be that:

    git config --global user.email "(none)"
    

    was a viable way for people to force themselves to set user.email in
    each repository.
    This was helpful for people with more than one email address, targeting different email addresses for different clones, as it barred git from creating a commit unless the user.email config was set in the per-repo config to the correct email address.

    A recent change, 19ce497 (ident: keep a flag for bogus
    default_email, 2015-12-10 for git 2.6.5, Jan. 2016), however, declared that an explicitly configured user.email is not bogus, no matter what its value is, so this hack no longer works.

    Provide the same functionality by adding a new configuration variable user.useConfigOnly; when this variable is set, the
    user must explicitly set user.email configuration
    .

    So starting March 2016 and git 2.8, do:

    git config --global user.useConfigOnly true
    

    Any of your new repo will look for user.email only in their local .git/config file.
    And the commit will not proceed if no user.email is found in the local git config.


    Note that it will be enhanced some more in git 2.9 (June 2016):

    See commit d3c06c1, commit 734c778 (30 Mar 2016) by Marios Titas (“).
    (Merged by Junio C Hamano — gitster — in commit e7e6826, 29 Apr 2016)

    ident: check for useConfigOnly before auto-detection of name/email

    If user.useConfigOnly is set, it does not make sense to try to auto-detect the name and/or the email.
    The auto-detection may even result in a bogus name and trigger an error message.

    ident: give “please tell me” message upon useConfigOnly error

    use a less descriptive error message to discourage users from disabling user.useConfigOnly configuration variable to work around this error condition. We want to encourage them to set user.name or user.email instead.

    So instead of:

    user.useConfigOnly set but no name given
    user.useConfigOnly set but no mail given
    

    You will see:

    no name was given and auto-detection is disabled
    no email was given and auto-detection is disabled
    

    Original answer (Sept. 2012)

    A bit like in “Stop a git commit by a specific author using pre-commit hook“, you could define a default pre-commit hook which check if:

     git config --local user.email
    

    is empty or not.
    If it is empty: exit 1

    To make sure you are using that default hook for every repo you are creating, see “change default git hooks“.
    It is a similar approach that the one described in “Share your git hooks“:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form field that contains one , or several Complete email addresses.
A column in my table contains email addresses. I have a text string that
I have 2 separate java services that use a complex type that is a
Do I need to have separate/multiple workers to run multiple websites (each with a
In my ASP.NET application I have separate projects for the Data, Business and UI
I have a website that is mirrored cross two sub-domains. So I have separate
I use subversion to manage my yii website (php framework) and have separate backend
I would like to capture email addresses with this form: I have decided to
I need to count the number of email addresses that a user inputs. Those
Say I have the following email addresses comma separated in a string: $addrList =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.