How to use 2 different global git configs?

I am using the github client and sourcetree by atlassian. I wanted to use 2 different global git configs for each software.

At the moment I have to edit and check every commit my autor and email name.

  • How do Git merges handle simultaneous commits?
  • Why does git call me “clever” when I reword the last commit message?
  • apparently same commits give different sha1, why?
  • Unversion on Git
  • GIT: commit changes to old/safe branch while in new/dirty/dev branch without checking out or losing unstaged data
  • How to commit no change and new message?
  • So how can I specify a unique config for each git program that I use.

    king regards

  • Removing a file that looks like “\357\275\236”
  • Jenkins - Unable to git clone from slave node. SSH keys
  • git svn fetch fatal: write error: Invalid argument
  • How to remove remote git urls from xcode?
  • Git: Show every line added by user in current branch
  • How to apply SVN diff to Git?
  • 2 Solutions collect form web for “How to use 2 different global git configs?”

    Each repo has its own configuration, which can override the system-wide and global configurations.
    Just enter each repo and

    git config user.name xxxx
    git config user.email yyyy
    

    Note the lack of the --global option.

    I was inspired by the answer of SzG. That is my final solution:

    At first have a look for the global git config. You find the .gitconfig inside your home directory (on windows: %userprofile%\.gitconfig, on linux: ~/.gitconfig).

    I created 2 Batches in the directory of the global git config file.

    GitHub.bat & SourceTree.bat

    GitHub.bat

    @echo off
    cd /D %userprofile%
    del .gitconfig
    copy GitHub.bat .gitconfig
    

    GitHub

    [user]
        name = Name1
        email = email1@example.com
    [core]
        autocrlf = true
        excludesfile = C:\\Users\\{windowsusername}\\Documents\\gitignore_global.txt
    

    SourceTree.bat

    @echo off
    cd /D %userprofile%
    del .gitconfig
    copy SourceTree.bat .gitconfig
    

    SourceTree

    [user]
        name = Name2
        email = email2@example.com
    [core]
        autocrlf = true
        excludesfile = C:\\Users\\{windowsusername}\\Documents\\gitignore_global.txt
    

    So this is working fine, just have to run one of these batches before commiting and i can use 2 different autor names with different email.

    Git Baby is a git and github fan, let's start git clone.