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

标签 windows git windows-7

假设我在 Windows 7 中的用户名是 C​​aesar。当我打开 Git Bash 时,我看到类似的东西

Caesar@COMPUTER-NAME$

是否可以将我的用户名更改为小写(以便它与我拥有的各种 Linux 服务器一致):

caesar@COMPUTER-NAME$

附言在 cygwin 中,可以以一种明显的方式编辑 /etc/passwd 来实现这一点,但是 git bash 没有这样的文件(可能有用)。

最佳答案

您可以使用 ssh_config 工具指定不同的用户名。有关详细信息,请参阅 ssh_config 联机帮助页,但简要说明:

创建文件 ~/.ssh/config,并在其中放入以下行:

User caesar

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

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

通常,~/.ssh/config 文件必须有模式 600,但 Git windows 版本似乎没有必要。

关于windows - 如何在 Windows 上更改 git bash 用户名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7816131/

相关文章:

git - 如何在 "git push -u <remote-name> <remote-branch-name>"中自动使用本地分支名称

javascript - 如何在网站上嵌入 github git README 文件

git rebase 与分支上的最后一次提交

networking - Windows 7 或 Vista TCP 行为更改

c# 通过系统扬声器发出哔哔声 - 直接访问 sys.扬声器

c# - OpenFileDialog 文件名为 UTF8

windows - 手动删除 Hyper-V 中的 MobyLinuxVM 后,Windows 10 上的 Docker 无法启动

windows - 无法在 Vagrant 安装的 Windows 2008 R2 Standard 中运行 PowerShell 脚本

css - chrome 中不需要的单杠

python - 如何从子进程中获取环境?