Git adds multiple URLs to the remote database, giturl. Git adds multiple url addresses to the remote library. the giturl Directory [-] uses the process principle for parsing. Note that Other can be found at: shede333 homepage: my. oschina. netshede333http: git adds multiple URLs to the remote library, giturl
Directory [-]
- Prerequisites
- Procedure
- Principle analysis
- Note:
- Other
- References
Author: shede333
Home: http://my.oschina.net/shede333 & http://blog.sina.com.cn/u/1509658847
Copyright Statement: original article, copyright statement: free reprint-Non Commercial-non derivative-keep the signature | [Creative Commons BY-NC-ND 3.0] []
Prerequisites
Generally, we add remote libraries for git, which are
git remote add origin
(You can use real addresses instead \ )
However, you may want to push your local git library to github and open source China's Git @ OSC. how can this problem be solved.
Someone may use two or more remote libraries, that is, add another remote library.git remote add origin2
;
This method is very inefficient, because you need git push twice to complete the push to two libraries.
In fact, there is another way: a remote git database can correspond to multiple addresses, that is, I can make the remote library origin have multiple url addresses. The method is as follows:
Procedure
First, we start from scratch. assume that you want to add three remote database addresses:
\ 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.git remote add origin
Then add the second address.git remote set-url --add origin
Add the third addressgit remote set-url --add origin
... And so on
In this way, you can add multiple addresses to the origin database.git push origin master
You can push to the three databases at a time (usegit push
OR)
Principle analysis
git remote set-url --add origin
Is to the current git projectConfig fileAdd a record
Config fileThere are two open methods:
Every time you executegit remote set-url --add origin
A row is added, for example:
git remote -v
: Displays the details of all the current remote databases in the formatRemote Database name url connection (type)
Therefore, you can directly add a url in the config file to modify the file. you do not have to execute the git command.
Note:
Usegit push origin master
You can push to multiple origin URLs,
Howevergit pull
Only one url address (fetch-url, for example) in the origin can be pulled. the default fetch-url isThe first address you added to the origin,
If you want to change it, you only need to change the order of the three URLs in the config file. fetch-url will directly correspond to the top utl connection.
Other
I recently saw this article, which is similar in principle: hosting the project to Github and Git @ OSC at the same time
If you are interested, you can check it out.
References
IDEA/Git sets up multiple push remote repositories or submits multiple push repositories at the same time
From: http://my.oschina.net/shede333/blog/299032
Http://www.bkjia.com/PHPjc/1114476.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1114476.htmlTechArticlegit to the remote library to add multiple url addresses, giturl Directory [-] The premise of the use of flow principle analysis note Other Reference Author: shede333 homepage: http://my.oschina.net/shede333http...