Git makes it easy to add remote repositories to push to, best part is you can use ssh.
The ‘git remote add’ command takes in a html URL like parameter for even SSH like:
ssh://<user>@<host>/<path to git repo>/
NOT the standard ssh scp syntax:
ssh://<user>@<host>:<path to repo>/
Which allows you to base the location from the users home directory or specify a full path:
firstname.lastname@example.org:<repo in home directory>/
email@example.com:/home/matt/<repo in home directory>/
NOTE: Just put a full path after the ‘:’, or if you want something from the home directory the just assume your in the homedir with out a starting ‘/’.
OK so git doesn’t seem to like that syntax, which is a shame because those of us who use ssh are SO used to it.
The good news is you can specify from the home directory with the git URL style syntax as you do with the standard URL sytax and it looks like:
ssh://matt@notrealhost/~/<repo in home directory>/
Those Linux/Unix guys will recognise the ‘~’ as a shortcut to home in bash, which means the same thing here!
So putting it all together I can add a remote to a git repository which exists in my home directory on that server by:
git remote add notrealhost ssh://firstname.lastname@example.org/~/code/myRepository/
This post was written because I keep trying to use the scp syntax when dealing with ssh + git.. So its being filled away here for my own reference.