Question

I've on my laptop a git repository, and a remote repository on GiHub (a straight forward configuration created when running 'git clone').

I'm using the SSH transfer protocol. i.e. remote address is: git@github.com:MyName/MyProg.git

I'm now in a network environment where port 23 is blocked (As far as I can see, only ports 80 and 443 are open). I need to fetch/merge recent changes available on the server. What are my options? If possible, I'd like to avoid creating a new remote branch with the http protocol (which is basically identical to the remote branch I already have).

Était-ce utile?

La solution

You could change url of the origin:

git remote set-url origin https://github.com/MyName/MyProg.git

and work as usual. Then change it back if port unblocked.

Second approach. You could change port which ssh uses by its config. github also provides ssh connection via port 443. For this you need to create a file ~/.ssh/config with the following content:

Host github.com
  Hostname ssh.github.com
  Port 443

For debugging you could use ssh -v git@github.com.

BTW, ssh port is number 22, not 23.

Autres conseils

You can simply change the url in the .git/config file to the one you want by editing the file directly or by using git config or git remote set-url.

But you would not need to create a new remote branch. What you meant is that you did not want another remote tracking branch; the above would do the trick.

Having another remote pointing to an alternate url is just fine. You can add it this way:

git remote add alternate https://github.com/account/repo.git

There is no inefficiency that it brings. So instead of doing

git fetch 

you now will specify which one with

git fetch origin

or

git fetch alternate

You can give remotes whatever names you want.

same thing with git push. You can specify to the degree you want and setup defaults if you don't specify.

Add New Remote for Alternate Protocol

You can have multiple remotes for a repository. You can add an alternative remote with a different URI scheme, even if it points to the same underlying repository. For example, to pull from a remote named "alternate" into your master branch:

git remote add alternate https://github.com/MyName/MyProg.git
git checkout master
git pull alternate master

Since the underlying repository is the same, this should not have any impact on your history. History will be the same whether you use the SSH or HTTPS protocols.

Without adding the temporary remote, you can fetch from a temporary target as follows

git fetch https://mytoken@github.com/<username>/<repo.git> master:remotes/origin/master

Which will update origin/master refspec from the master branch on the that temp remote url.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top