Cheng Yu


Create code repository

Use gitee as an example (GitHub is similar to gitee)

1. Click + in the upper right corner of gitee and select new warehouse

2. Select to fill in warehouse information and create it

3. The server is ready. Start to prepare locally

(1) Git global settings

git config --global  "Chengyu"
git config --global "[email protected]"

(2) Create local git repository

#Create folder
mkdir test
#Enter folder
cd test
git init
#Creating files
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

(3) Existing warehouse

cd existing_test
git remote add origin
git push -u origin master

The local library is associated with both GitHub and gitee

After the above steps, you can create a remote repository in GitHub and gitee. Some friends can want to maintain their own code to gitee and GitHub. Two warehouses can be associated locally. You can choose to submit to different warehouses. The next steps are to set up a local association of two warehouses.

(1) View the local association (you can see that the local library is already associatedoriginAnd the remote library points to gitee)

git remote -v

origin (fetch)
origin (push)

(2) We can delete the existing gitee remote library, first associate GitHub remote library, and then associate gitee remote library

#Delete local association
git remote rm origin
#Associate GitHub
git remote add github
#Associated gitee
git remote add gitee

(3) We use itgit remote -vViewing the remote library information, you can see two remote libraries

gitee (fetch)
gitee (push)
github (fetch)
github (push)

(4) Push code

If you want to push to GitHub, use the command

git push github master

If you want to push to gitee, use the command

git push gitee master

Local and remote association graph (so that the local library can synchronize with multiple remote libraries at the same time)

How far library submit pull code in idea

1. Pull code (click pull to select different remote warehouses)


2. Submit code (first submit to the local warehouse, then push to the remote warehouse, and then push to the remote warehouse, which is also optional)


I hope this article can help you.