Is it possible to have different Git configuration for different projects?

前端 未结 12 774
萌比男神i
萌比男神i 2020-12-02 03:44

.gitconfig is usually stored in the user.home directory.

I use a different identity to work on projects for Company A and something else fo

12条回答
  •  孤城傲影
    2020-12-02 04:04

    Another way is to use direnv and to separate config files per directory. For example:

    .
    ├── companyA
    │  ├── .envrc
    │  └── .gitconfig
    ├── companyB
    │  ├── .envrc
    │  └── .gitconfig
    └── personal
       ├── .envrc
       └── .gitconfig
    

    Each .envrc should contain something like this:

    export GIT_CONFIG=$(pwd)/.gitconfig
    

    And .gitconfig is usual gitconfig with desired values.

提交回复
热议问题