git create a new local library and upload it to a remote library

1. Create a project


Click Enter image descriptionor Enter image descriptionin the upper right corner to jump to the project creation page:

Enter image description

Fill in the information in turn and click Create, so we have created a project. If there is no accident, you will see this page:

Enter image description

In this way, we have created a project on the code cloud platform

2. Initialize a project locally


First, you need to execute the following two commands, as the basic configuration of git, the role is to tell git who you are, and the information you enter will appear in the commits you create.

git config --global user.name "你的名字或昵称"
git config --global user.email "你的邮箱"

Then execute in your folder where you need to initialize the repository:

git init 
git remote add origin <你的项目地址> //:项目地址形式为:http://git.oschina.net/xxx/xxx.git或者 git@git.oschina.net:xxx/xxx.git

This completes a version of your initialization.

If you want to clone a project, just execute:

git clone <项目地址>

3. Complete the first submission


Go to the directory of your initialized or cloned project and execute:

git pull origin master
<这里需要修改/添加文件,否则与原文件相比就没有变动>
git add .
git commit -m "第一次提交"
git push origin master

Private project: You will be prompted to enter username -> login email account -> prompt to enter password -> login password

Then if you need an account password, enter the account password, and this completes a submission.

At this point, you can view your commit records on your personal panel and project homepage, for example: http://git.oschina.net/oschina/git-osc/commit/f3dd1c5bae48fa4244e2595a39e750e5606dd9be](http://git.oschina .net/oschina/git-osc/commit/f3dd1c5bae48fa4244e2595a39e750e5606dd9be

When a new project is created according to this document, the readme file already exists in the code cloud platform warehouse, so there may be conflicts when submitting it. In this case, you need to choose to keep the online files or discard the online files. For online files, select forced push when pushing. Force push requires the execution of the following commands:

git push origin master -f

If you choose to keep the readme file online, you need to execute:

git pull origin master

Then you can push. If there is a conflict, you need to resolve the conflict first. For how to deal with conflicts, please refer to the section on how to deal with code conflicts .

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326592261&siteId=291194637
Recommended