Uploading local files to GitHub

Source: Internet
Author: User
Tags using git

First step: Download the Git tool and choose the appropriate version to install

Step two: Open git bash after the installation is complete, enter your username and email

$ git config --global user.name "LeavesYan"

$ git config --global user.email "[email protected]"

Step three: Generate the key

$ ssh-keygen-t rsa-c "[Email protected]"

Press the ENTER key 3 times during the build process (default path, no password login by default).

Fourth step: Set SSH key

After the success of the previous step, go to the default path with Notepad open id_rsa.pub, get SSH key public key.

You can verify that the key is generated by this machine:

$ CD ~/.ssh

$ ls

If the result is as follows, the key already exists:

Fifth Step: Configure Sshkey for GitHub account

Click on your avatar in the top right corner, then click Setting, and find SSH and GPG keys in the menu bar on the right. Click New SSH key, enter title, the following key is the local SSH key public key, directly paste the contents of Id_rsa.pub, and then click on the following Add SSH key to complete.

Sixth step: Upload Local files

1. Create a local warehouse

(1) Enter the folder

(2) The execution instruction is initialized, and a hidden folder is generated in the original folder. Git

(3) If you do not create a local repository in the folder where the project is located, you can paste the item into this local git repository (you can view the current status by using Git status after pasting)

(4) Add the project to the warehouse by using git Add.

(5) Prepare the tracked files for the changes in the staging area, submit the project to the warehouse via Git commit, and enclose the contents in single quotation marks

2. Create a git repository on GitHub

Click New Repository to create

3. Local warehouse related to GitHub warehouse

After you copy the warehouse address, execute the command

4. Push all the contents of the local warehouse to the remote repository

The first time you execute it, you can use: $ Git push-u origin Master

Attention:

Error one that may occur during:

Fatal:remote origin already exists, performed by:

$ git Remote RM origin

Then re-execute:

$ git Remote add Origin https://github.com/LeavesYan/LibManage.git

$ GIT push origin master

Errors that may occur during the second:

Failed to push som refs to, which is due to the creation of the Git repository, check the Initialize this repository with a Readme (the creation of the warehouse automatically when you create a readme file), and the new The Readme file in the repository is not in the local repository directory, we can merge the content with the following command:

$ git Pull--rebase Origin master

This instruction means to merge the updates from the remote repository into the local repository, and the –rebase is to cancel the commit that was just made in the local repository and send them to the updated repository.

$ GIT push origin master

Push to Succeed!

Uploading local files 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.