search

Home  >  Q&A  >  body text

github - How to use git to link two remote servers without configuring ssh.

Hello everyone, I want to push git to two servers at the same time. How many SSHs do I need to configure?

My situation:
I first configured github's ssh, but I also want to deploy it to oschina at the same time. Do I also need to configure an ssh? But doesn’t this conflict with github’s ssh? At the same time, push cannot be done on github, but can only be pushed to oschina.

Or is it like what most people on the Internet say? After I configure GitHub's ssh, I don't care, just like the following?

[remote "all"]  
    url = https://github.com/XXXXXX/XXXXX.git  
    url = https://git.oschina.net/XXXXX/XXXXX.git

Xiaobai thanks the respondent in advance (three bows)

怪我咯怪我咯2801 days ago974

reply all(2)I'll reply

  • 某草草

    某草草2017-05-02 09:51:20

    If git supports pushing to multiple servers at the same time, you can use the following command

    git remote set-url --add <name> <newurl>

    If you already have the default remote host origin which is GitHub, you can use the following method to add the address of oschina to origin

    git remote set-url --add origin <oschina url>

    In this way git push origin you can submit to GitHub and oschina at the same time.

    git-remote

    If you type on your mobile phone, the formatting is wrong and I will change it on my computer.

    reply
    0
  • 迷茫

    迷茫2017-05-02 09:51:20

    If you want to push to two servers, you only need to set up two remotes, and then push your own branch.

    git remote add github <github-repo>
    git remote add oschina <oschina-repo>
    git push github master
    git push oschina master

    Also, you can refer to the list I made about the remote warehouse git cheat sheet

    reply
    0
  • Cancelreply