Can I specify multiple users for myself in .gitconfig?

后端 未结 20 2732
无人及你
无人及你 2020-11-22 06:33

In my ~/.gitconfig, I list my personal email address under [user], since that\'s what I want to use for Github repos.

But, I\'ve recently s

20条回答
  •  离开以前
    2020-11-22 06:52

    There is a simple solution that seems to work well for avoiding mistakes.

    Simply remove the [user] section from your ~/.gitconfig, which will prevent you from making any commits without setting user.name for each repository.

    In your ~/.bashrc, add some simple aliases for the user and email:

    alias ggmail='git config user.name "My Name";git config user.email me@gmail.com'
    alias gwork='git config user.name "My Name";git config user.email me@work.job'
    

提交回复
热议问题