Using git with ssh running on a non-standard port

Yesterday I needed to be able to specify a port with a git clone command, because the git server runs ssh on a non-standard port. In short, the solution was to put this text in my ~/.ssh/config file:

Port 5150
User gituser

Without looking into this deeper, I’m not sure if the HostName is needed, but I can confirm that the Host field needs to match the server you’re attempting to access, because I fat-fingered the Host on my first try, and it didn’t work.

Once that was set, I was able to run my git clone command using a normal ssh URL like this:

$ ssh://

Note that the general form of the git ssh commands looks like the following examples:

$ git clone ssh://user@server/project.git
$ git clone user@server:project.git

I found the first answer here on SO, and I found the last two git clone examples at this URL.