Use git to upload files to the Github / Gitee

Introduction: a brief introduction to the local file using git pushed to Github / Gitee

Proceed as follows:

0. create the repository

Whether Github or Gitee, must create the appropriate warehouse (repository) before uploading files

image-20200219224325936

image-20200219224407034

1. Open the git bash

The need to upload a local folder open right git bash:

image-20200219224731076

2.git init

Enter the git init command, create a local repository in the folder:

image-20200219224948161

3.git add .

Enter the git add. Command, add all the files in that folder to a local warehouse. "." Is to add all files can. "" Replaced with the corresponding file name if you want to add individual files.

image-20200219225312380

4.git commit -m "comment"

Enter git commit -m "first update" command, git commit -m (file that is added in one step on) role for the submission of documents staging area, you can fill annotation information on the submission within double quotes back, here is written, " first update ".

image-20200219225836144

5.git remote add origin remote warehouse address

Enter the Add Remote Origin git https://github.com/AhuntSun/JavaScript-.git or

the Add Remote Origin git https://gitee.com/ahuntsun/Test.git instructions associated with the remote repository local repository, instruction behind the address Github / Gitee the address of the original target warehouse or warehouse just created. Next to the warehouse on Gitee example.

image-20200219230327286

image-20200219230352725

image-20200219230509698

6.git pull --rebase origin master

Enter git pull --rebase origin master instruction, the contents of the remote repository into a local warehouse. If a remote warehouse is empty you can skip this step if the remote repository is not empty, it must be this step, otherwise it will error.

image-20200219231006483

image-20200219231021740

image-20200219231043888

7.git push -u origin master

Enter git push -u origin master instruction, the local repository of files pushed to the remote repository master branch has been established in association.

image-20200219231317187

After command execution can ask to see a local file upload in a remote repository:

image-20200219231425353

If the remote repository is not empty, and no step 6, the following error occurs when executing instructions Step 7:

image-20200219231725132

8.git status

Finally git status command input can view the status of the local repository, this step can be omitted.

image-20200219231946879

Github push files sent is the same step.

As long as the establishment of a local warehouse associated with the remote repository folder, and then upload the files within that folder only need to enter the command to step 3,4,7.

Guess you like

Origin www.cnblogs.com/AhuntSun-blog/p/12333908.html