Upload local code to GitHub

Source: Internet
Author: User

This operation needs to use the management tool git,:https://git-scm.com/

Once installed, open the project folder you want to upload, right-click on the Windows system select Git Bash here

The transfer between 1.git and GitHub is encrypted via SSH, so the first step is to generate one locally. SSH (there is not much explanation for the GitHub registration steps here).

1) First check if there is a. ssh file on the local, and some delete it.

$ CD ~/.ssh

2) Enter the command, generate. SSH, write your own mailbox

$ ssh-keygen-t rsa-c "Your [email protected]"

You can go straight to the carriage

This means that a. ssh file will be generated at the root of the user directory in the C drive, and if you can't find it, you can search for it, and there will be Id_rsa and Id_rsa.pug files under the file.

3) In order to avoid errors when creating a connection with GitHub, you can create a new config file and copy the following code in

Host github.com    User git    Hostname ssh.github.com    preferredauthentications publickey    identityfile ~/ . Ssh/id_rsa    Port 443
 

2. Add a public key to GitHub

1) Copy the contents of the Id_rsa.pug to the specified location

2) test the connection is successful, indicating successful access

$ ssh-t [email protected]

3. Uploading a project

1) Create git config file, you will find a. git file under your file, default is hidden file

$ git init

2) Add all current files to GitHub

3) Confirm Add

$ git commit-m "first commit"

4) Execute the command, and copy back the generated on your GitHub

$ git Remote add origin [email protected]:heshaui/pdfjsdemo.git

May be wrong

Workaround:

First enter: $ git Remote RM origin

Re-enter: $ git Remote add origin [email protected]:heshaui/pdfjsdemo.git

5) Execute last command

$ Git push-u Origin Master

If you use Git to push the source code to GitHub, you may get an error, as follows

The main reason for the error is that the readme.md file in GitHub is not in the local code directory

You can merge the code with the following command: Pull=fetch+merge

Git pull--rebase Origin master

After executing the above code, you can see that the local code base has more readme.md files

Now execute the statement GIT push-u Origin master to complete the code upload to GitHub

So the project was uploaded successfully.

Upload local code 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.