Article Directory
Preface
Recently, I plan to host the code of the previous project on GitHub. Considering future factors, I also established a warehouse on Gitee. This article introduces how to use Git to host projects to both GitHub and Gitee repositories.
Of course, the premise is that you have installed Git and registered GitHub and Gitee accounts.
1. Create a GitHub repository
Warehouse name testone
, add a project description, check it Public
, then add a README
file, and finally click Create repository
Create Warehouse. As shown below:
2. Build a Gitee warehouse
Click Code
, copy the address link of the GitHub warehouse first, then go to Gitee to create the warehouse, drop down the page, click 导入已有仓库
, copy the address link of the GitHub warehouse, and click 创建
.
The protocol type can be unselected
3. Clone the GitHub repository to the local
Right-click to open the local folder Git Bash
, and then clone the GitHub repository you just created to the local. The clone command is as follows:
git clone https://github.com/xiayouran/testone.git
After cloning, there will be a folder in the current directory, the name of the folder is the warehouse name, and then enter this folder:
cd testone
Then create a file in the current folder test.txt
, write some content and save it.
4. Push the updated project
Check the status first, the font is red:
git status
Then use the following command to add all the files in this folder to the temporary storage area
git add .
Check the status again. At this time, the font is green, indicating that it has been added to the local project:
Then add the submission description through the following command, without this submission:
git commit -m 'submit a txt file'
Then use the following command to add the Gitee warehouse address to the existing remote locally:
git remote set-url --add origin https://gitee.com/xiayouran/testone.git
Then push through the following command:
git push
Refresh the respective warehouse, you can see that the test.txt
file has been pushed to the warehouse: