Git

git config --global user.name
git config --global user.email

git config --global --get user.name
git config --global --get user.email

git如何为内外网配置不同的username?

  1. 修改 ~/.gitconfig 文件:

# see https://git-scm.com/docs/git-config#_conditional_includes
[includeIf "gitdir:github.com/"]
    path = ./.github

[includeIf "gitdir:gitlab.xx.com/"]
    path = ./.gitlab
  1. 新增 ~/.github~/.gitlab 文件:

# .github
[user]
    email = a
    name = a
    
# .gitlab
[user]
    email = b
    name = b

将 http 方式替换为 ssh

修改 ~/.gitconfig 文件:

[url "git@gitlab.xxx.com:"]
    insteadOf = https://gitlab.xxx.com/
[url "git@gitlab.xxx.com:"]
    insteadOf = http://gitlab.xxx.com

Last updated