Create a project on Gitee and GitHub

The user name is admin and the warehouse name is demo

Clone the project to the local

Direct download

Use names locally

/ / to get $from gitee git clone https://gitee.com/admin/demo.git / / out access $git clone https://github.com/admin/demo.gitCopy the code

Custom associated remote libraries

  1. Delete GIt default remote library name
$git remote rm origin $git remote rm originCopy the code
  1. Associate Gitee and GitHub respectively and set names
/ / associated gitee and set up an alias for gitee $git remote add gitee @ git/gitee.com: admin/demo git / / association making and set up an alias for making $git remote add githob  @git/github.com:admin/demo.gitCopy the code

Push to the remote repository

$git push GitHub $git push GitHub masterCopy the code

Possible errors

This prompts you to reject the update and to pull from the remote first and then try again

$ git push github master To github.com:admin/demo.git ! [rejected] master -> master (fetch first) ... .Copy the code

The solution

Pull out

 $ git pull github master
Copy the code

Push to the Github remote repository

 $ git push github master
 
Copy the code

It might say push failed and you can try to force push here

$ git push github master -f
Copy the code

As the project is initialized and pulled from the remote warehouse, the use of forced push will not affect the project, and it is generally not recommended

At this point, the local library can synchronize with multiple remote libraries simultaneously

Upload Git code to GitHub and Gitee at the same time