To clone a repository managed by gitolite one usually uses following syntax
git clone gitolite@server:repository
This tells the SSH client to connect to port 22 of server using gitolite as user name. When I try it with the port number:
git clone gitolite@server:22:repository
Git complains that the repository 22:repository is not available. What syntax should be used if the SSH server uses a different port?
The “SCP style” Git URL syntax (user@server:path
) does not support including a port. To include a port, you must use an ssh://
“Git URL”. For example:
ssh://gitolite@server:2222/repository
Note: As compared to gitolite@server:repository
, this presents a slightly different repository path to the remote end (the absolute /repository
instead of the relative path repository
); Gitolite accepts both types of paths, other systems may vary.
An alternative is to use a Host
entry in your ~/.ssh/config
(see your ssh_config(5) manpage). With such an entry, you can create an “SSH host nickname” that incorporates the server name/address, the remote user name, and the non-default port number (as well as any other SSH options you might like):
Host gitolite
User gitolite
HostName server
Port 2222
Then you can use very simple Git URLs like gitolite:repository
.
If you have to document (and or configure) this for multiple people, I would go with ssh://
URLs, since there is no extra configuration involved.
If this is just for you (especially if you might end up accessing multiple repositories from the same server), it might be nice to have the SSH host nickname to save some typing.