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.

  • What is the effect of git commit without the -a option?
  • How do I reverse a commit in git?
  • How to list stats of resolved conflicts in a merge commit?
  • How to set git commit --author properly from rake running under LocalSystem account?
  • How move all commits from specific user to a new branch?
  • Move tag one commit ahead
  • So how can I specify a unique config for each git program that I use.

    king regards

  • Is it possible to compile bitbucket dependency via SSH (Gradle)?
  • Set up git to pull and push all branches
  • Problems with git submodules when submodules are private Github repos
  • Starting from scratch for v2.0. Should I keep using the existing git repo or start a new one?
  • How to clean all commits from remote github repo
  • Keeping a branch up to date with master
  • 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.