且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows上更改git bash用户名?

更新时间:2022-12-04 19:55:24

您可以使用ssh_config工具指定其他用户名.有关详细信息,请参见ssh_config联机帮助页,但简要介绍一下:

You can use the ssh_config facility to specify a different username. See an ssh_config manpage for details, but briefly:

创建文件~/.ssh/config,然后将以下行放入其中:

Create the file ~/.ssh/config, and put just this line in it:

User caesar

如果不同主机的用户名不同,则可以使用主机"设置指定不同的用户名,包括默认的用户名:

If you have different usernames for different hosts, you can use the Host setting to specify different usernames, including the default one:

Host rome1
  User caesar
Host rome2
  User brutus
Host *
  User romeo

通常,~/.ssh/config文件必须具有模式600,但是对于Git Windows版本似乎不是必需的.

Normally, the ~/.ssh/config file has to have mode 600, but that doesn't seem to be necessary for the Git windows version.