GIT - Gitee 与 Github

Essay Record - From https://www.liaoxuefeng.com/wiki/896043488029600/1163625339727712

 

Project name had better be consistent with the local library:

We then use the command on the local repository git remote add it to the library and code associated with the remote cloud:

git remote add origin [email protected]: uuid / learngit.git
After that, you can normally use git push and git pull push up!

If the error in using the git remote add command:

the Add Remote [email protected] origin git: uuid / learngit.git
fatal: Remote origin already EXISTS.
This shows that local libraries have been associated with a remote library named origin, in which case, you can view the remote repository with git remote -v information:

Remote -v git
origin [email protected]: UUID1 / learngit.git (FETCH)
origin [email protected]: UUID1 / learngit.git (the Push)
you can see, the local library has been associated with the origin of the remote repository, and, the remote library pointing GitHub.

We can delete the existing remote GitHub repository:

git remote rm origin
re-associated code cloud-based remote library (note that the path need to fill in the correct user name):

git remote add origin [email protected]: uuid / learngit.git
At this point, we'll see the remote library information:

Remote -v git
Origin [email protected]: uuid / learngit.git (FETCH)
Origin [email protected]: uuid / learngit.git (the Push)
can now be seen, origin code has been linked to the cloud-based remote library . By git push command can be pushed to the local library on Gitee.

Some small partners have to ask, can not be associated with a local library GitHub both, and the associated code cloud it?

The answer is yes, because git itself is a distributed version control system, can be synchronized to another remote repository, of course, the other two can be synchronized to a remote database.

When using multiple remote libraries, we should note that the default name to a remote git repository from that origin, if there are multiple remote repository, we need to use different names to identify different remote library.

Still learngit local library, for example, we drop the remote library has been associated with the origin of the name:

git remote rm origin
and then, the first association of remote GitHub repository:

git remote add github [email protected]: uuid1 / learngit.git
Note that the name of the remote database called github, do not call the origin.

Then, re-association code cloud-based remote library:

git remote add gitee [email protected]: uuid / learngit.git
Also note that the name of the remote database called gitee, do not call origin.

Now, we see the remote database information with git remote -v, you can see two remote libraries:

-v remote git
gitee gitgiteecom: uuid / learngitgit (fetch)
gitee gitgiteecom: uuid / learngitgit (the push)
github gitgithubcom: uuid1 / learngitgit (fetch)
github gitgithubcom: uuid1 / learngitgit (the push)
ru_guo yao tui song_dao GitHub, shi_yong ming_ling:

git push github master
To push cloud code, use the command:

git push gitee master

As a result, our local library can be synchronized with each other simultaneously with multiple remote database:

┌─────────┐ ┌─────────┐
│ GitHub  │ │  Gitee  │
└─────────┘ └─────────┘
     ▲           ▲
     └─────┬─────┘
           │
    ┌─────────────┐
    │ Local Repo  │
    └─────────────┘

Guess you like

Origin www.cnblogs.com/zhwanwan/p/11805280.html