windowsgitwindows-7

How to change the git bash username on Windows?


Assume that my username in Windows 7 is Caesar. When I open Git Bash I am greeted with something like

Caesar@COMPUTER-NAME$

Is it possible to change my username to be lowercase (so that it agrees with various Linux servers I have):

caesar@COMPUTER-NAME$

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).


Solution

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

    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
    

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