git remote add with other SSH port

In Git, how can I add a remote origin server when my host uses a different SSH port?

git remote add origin ssh://user@host/srv/git/example

  • Can Install EGit: Missing requirement: Git Team Provider Core
  • get short sha of commit with gitpython
  • How to push 'refs/replace' without pushing any other refs in git?
  • Git hash search engine
  • git clone requires ssh:// protocol when perhaps it shouldn't?
  • Git ignore generated extensions
  • How to combine two branches from two different repositories in a single repository?
  • How to efficiently rebase and push a local git branch?
  • DAG vs. tree using Git?
  • How to push to github from cloud9?
  • git-svn dcommiting a single git commit
  • Number of commits on branch in git
  • 5 Solutions collect form web for “git remote add with other SSH port”

    You can just do this:

    git remote add origin ssh://user@host:1234/srv/git/example

    1234 is the ssh port being used

    You need to edit your ~/.ssh/config file. Add something like the following:

        Port 1234

    A quick google search shows a few different resources that explain it in more detail than me.

    For those of you editing the ./.git/config

    [remote "external"]                                                                                                                                                                                                                                                            
      url = ssh://                                                                                                                                                                                                               
      fetch = +refs/heads/*:refs/remotes/external/* 

    Best answer doesn’t work for me. I needed ssh:// from the beggining.

    # does not work
    git remote set-url origin
    # work
    git remote set-url origin ssh://

    Found this link, and although it was helpful my blog entry might help clarify it:

    Basically i think its much better to just edit your .git/config file and make the changes. Hopefully this will help someone else..

    Git Baby is a git and github fan, let's start git clone.