如何在Windows上更改git bash用户名? [英] How to change the git bash username on Windows?
问题描述
假设我在Windows 7中的用户名是Caesar.当我打开Git Bash时,会收到类似
Assume that my username in Windows 7 is Caesar. When I open Git Bash I am greeted with something like
Caesar @ COMPUTER-NAME $
Caesar@COMPUTER-NAME$
是否可以将用户名更改为小写(以便与我拥有的各种Linux服务器一致):
Is it possible to change my username to be lowercase (so that it agrees with various Linux servers I have):
caesar @ COMPUTER-NAME $
caesar@COMPUTER-NAME$
P.S.在cygwin中,可以用一种明显的方式编辑/etc/passwd
来实现这一点,但是git bash没有这样的文件(可能有用).
P.S. In cygwin, one can edit /etc/passwd
in an obvious way to achieve this, but there is no such file for git bash (might be useful).
推荐答案
您可以使用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.
这篇关于如何在Windows上更改git bash用户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!