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.

  • Git - Merging two commits which are not in serial sequence - Commits pushed to remote repo already
  • How do I specify the commit message in the pom when using scm-maven-plugin?
  • Git contains between arbitrary commits
  • Why all my Xcode commits to Bitbucket show other user 'Author Name' on Bitbucket?
  • How can I get/list/see all the descendants of a commit with git (or gitk)?
  • Undo delete in GIT
  • So how can I specify a unique config for each git program that I use.

    king regards

  • git-svn commits to wrong branch / how to merge svn branch via git-svn
  • msysgit32 insists on launching from HOMEDRIVE/HOMEPATH
  • Git diff branch - filter by extension?
  • git log doesn't work with both the --graph option and the --since/--until options
  • Git from the command line doesn't work, but using a git client (like SmartGit) does
  • Possible workflow with git submodules
  • 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.