Git usage-Upload a local project to GitHub

Source: Internet
Author: User

1. Create a new project (folder) and put it in the project you want to upload;

Test upload github is my new folder, Es6-setting-up-the-environment is the project I want to upload;

2. Go to D:\test upload GitHub, right-click Git bush here

3. Enter git init

Turn this folder into a repository that git can manage

You'll see a more. git folder in the folder, which Git uses to track and manage the repository. If you don't see it, because it's hidden by default, you need to set it up so that the hidden file is visible. and becomes the master branch (the right side of Git bash)

At this point git status, you can see yourself in the Master branch;

4. Although the project is in a local folder, but not add to the Git repository, then we

Enter git Add.

Add all the items you have just copied to the warehouse.

5. Enter git commit-m "Add your own comments"

Submit the project to the warehouse.

The following are all the files to be added

6. Because the transfer between the local git repository and the GitHub repository is encrypted via SSH, the connection needs to be set up:

Create an SSH KEY.

Take a look at your C-drive user directory there is no. ssh directory, some words to see if there is no Id_rsa and id_rsa.pub these two files, have jumped to the next step, did not create by the following command

Ssh-keygen " git-bound email address. com "

All the way to the carriage. At this point you will find the Id_rsa and id_rsa.pub two files in the. SSH directory under the user.

7: Login to GitHub and find the icon in the top right corner

Open the settings in the inside, then select the SSH and GPG keys, click on the upper right corner of the new SSH key, and then fill in the title,

Then the id_rsa.pub (the second file in the image above) is copied to the title under the Key Content box, and finally click on the Add SSH key, so that the completion of the SSH key encryption. (Note that there must be a public key (id_rsa.pub), and the private key cannot be given)

8. Create a git repository on GitHub.

Click on the upper right corner +, select New Repository, the following page appears.

Fill in the project name, description, bottom left corner to determine the creation of a new project

9. After creating a git repository on GitHub, we can associate it with the local repository, based on the prompt to create a good git repository page,

At the command line of the local warehouse, enter:

$ git Remote add origin https://github.com/sunmarvel/new-show

When the browser enters the GitHub project, the address of the browser is the HTTPS address, or the SSH address of the project page can be copied.

10. After the connection, we can push all the contents of the local repository to the remote repository (github) by:

Git push-u Origin Master

Since the new remote warehouse is empty, so to add-u this parameter, and so on the remote warehouse inside the content, the next time you upload content from the local library only

git push is ready.

11.bash input This line of code, will jump out of two pages, let you enter the GIT user name and password, input is OK

After the input is correct, it will automatically start uploading, and the process of uploading the project may take a while to complete:

This time you re-refresh your github page into the newly created warehouse and you will find that the project has been successfully uploaded:

Click on the folder name to the left to see the submitted file.

In addition, there is a pit to note, is in the 8th step above the creation of the remote repository, if you check the Initialize this repository with a readme (that is, when the warehouse is created automatically to create a Readme file), So in the 10th step, when you push the local repository content to the remote repository, you will be presented with a failed to push some the refs to https://project address error.

This is because the Readme file in your newly created warehouse is not in the local repository directory, so we can merge the following commands first:

$ git Pull--rebase Origin master

Then you can push and you will succeed.

Summary: In fact, only the following steps will be able to upload local projects to GitHub

1. Create a repository (i.e. a folder) locally and turn it into a git repository via git init;

2. Copy the project into this folder and add it through git. Adding items to the warehouse;

3, then through the git commit-m "comment content" to submit the project to the warehouse;

4. After setting the SSH key on GitHub, create a new remote repository to associate the local repository with the remote repository (git Remote Add Origin https://project address);

5, finally through the GIT push-u origin master to push the local warehouse project to the remote warehouse (that is, GitHub);

(If the new remote repository automatically created a Readme file will be error, the solution to see above).

Git usage-Upload a local project to GitHub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.