Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I set up default login name for git on Windows 7? When I run git clone ssh://<server>/repo, git tries to connect to user@<server>, where user is my Windows username. How can I change the default username for a given server? I cannot use ssh://<username>@<server>/repo.

share|improve this question
    
Why can't you use ssh://<username>@<server>/repo or <user>@<server>:repo syntax? –  Stephen Jennings Oct 27 '11 at 8:39
    
Because that does not help me. I also have submodules on the same server. When I use git and recursive clone, git creates new connections to the same server again with bad username, because the submodule url is without the username. –  Juraj Blaho Oct 27 '11 at 8:42

1 Answer 1

up vote 1 down vote accepted

For ssh connection, you can specify:

  • the server
  • the name
  • the private key

Example:

Host server
User yourLogin
Hostname SSH IP address --eg 192.68.24.1
IdentityFile "path to your private ssh key"

in a file named config (under your HOME/.ssh, provided you did defined the HOME environment variable, which isn't defined by default in Windows).

See a more complete example in "nbgit to remote host with ssh".

share|improve this answer
    
I already have the user.name set in the global git config. That does not work. –  Juraj Blaho Oct 27 '11 at 8:25
    
@JurajBlaho: sorry, I didn't see the ssh part! I have completely re-edited my answer. –  VonC Oct 27 '11 at 8:30
    
Where should I set that? I have an .ssh directory with known_hosts file in it. Where should I set the loginName and private key for the server? –  Juraj Blaho Oct 27 '11 at 8:37
    
@JurajBlaho: in that same .ssh directory, add a file named 'config' with your ssh connection. The link I mention illustrates how it works. –  VonC Oct 27 '11 at 8:40
    
It seems to do almost what I need. Thanks. –  Juraj Blaho Oct 27 '11 at 8:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.