Git adds multiple URL addresses to the remote library, giturl_php tutorial

Source: Internet
Author: User

Git adds multiple URL addresses to the remote library, Giturl


Catalogue [-]
    • Premise
    • Use process
    • Principle Analysis
    • Attention
    • Other
    • Reference articles

Author: shede333
Home: http://my.oschina.net/shede333 && http://blog.sina.com.cn/u/1509658847
Copyright Notice: Original article, copyright notice: Free Reprint-Non-commercial-non-derivative-maintain attribution | [Creative Commons by-nc-nd 3.0] []

Premise

In general, we add remote libraries to git, which are generally
git remote add origin (You can use a real address instead of \ )

But you might want to push your local git repository to GitHub and push it to the git@osc of open source China, how to solve it.
Some people may use two or more remote libraries, that is, add a remote library git remote add origin2 ;
This method is inefficient because you want git to push two times to complete the push to two libraries.

In fact, there is another way, a remote library of git can correspond to multiple addresses, that is, I can let the remote library origin has multiple URL addresses. Here's how:

Use process

First, we start from scratch, assuming that you now want to add 3 remote library addresses, respectively:

\ https://git.oschina.net/shede333/swioslibary.git
\ https://git.oschina.net/shede333/swscrollbar.git
\ https://github.com/shede333/CoreAnimationTestSW.git

First, add the first address firstgit remote add origin
Then add a second addressgit remote set-url --add origin
Add a third addressgit remote set-url --add origin
.... In turn

This completes the addition of more than one address to the Origin library, as long as the use of a single git push origin master push to 3 in the library ( git push can also be used)

Principle Analysis

git remote set-url --add originis to add a row of records to the config file for the current Git project.
There are two ways to open config files :

You add a line every time you execute git remote set-url --add origin it, such as:

git remote -v: Displays the details of all current remote libraries, displayed in the format远程库名字 url连接(类型)

Therefore, you can directly add the URL directly in the config to modify is also possible, do not have to execute the git command.

Attention

git push origin masterwhen used, you can push to multiple URL addresses of origin,
But git pull when used, you can only pull a URL address in origin (i.e., fetch-url, for example), and this fetch-url defaults to the first address you added to Origin.
If you want to change, only need to change the config file, the order of the three URLs, Fetch-url will directly correspond to the first UTL connection.

Other

I recently saw this article also good, similar principle: The project is hosted simultaneously to GitHub and Git@osc
be interested to see

Reference articles

Idea/git setting up multiple push remote warehouses or simultaneously submitting multiple push warehouses



From: http://my.oschina.net/shede333/blog/299032

http://www.bkjia.com/PHPjc/1114476.html www.bkjia.com true http://www.bkjia.com/PHPjc/1114476.html techarticle git adds multiple URL addresses to the remote repository, Giturl directory [-] premise Use flow principle Analysis Note Other reference article author: shede333 home: http://my.oschina.net/shede333http:/...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.