How to use Git to upload files to GitHub from this machine

Source: Internet
Author: User
Tags how to use git

First, download a git, install it.

After the installation is successful, enter the following command, in quotation marks for your own name and mailbox
git config--global user.name "Your name"
git config--global user.email "[Email protected]"

Create a repository, where the project is stored
mkdir file name

Initialize, after initialization, you can see a. git file in the directory by Ls-ah

GIT init (Initialize repository)

Add Files to Repository
Create a new file (test.html) and edit it first
git add test.html (submit only the current directory's test.html file to the local git repository)

The error message may appear as in

WARNING:LF is replaced by CRLF in test.html.
The file would have their original line endings in your working directory.

Workaround:

1. Enter again as above command, add a space after the command, enter

2, if still does not work, then executes the git config Core.autocrlf false command, executes the add command again to be successful.

Execute git Add. (Add all content to the index library)

Note that after the command there is a.

Submit
Git commit-m "wrote a Readme file" (submits the contents of the index library;-M is a parameter that represents the comment content, mainly used to record this operation)

Upload to GitHub
Use the following command to generate the RSA public key
Ssh-keygen-t rsa-c "[Email protected]" (change to your own mailbox)

Of course, the three storage address and other commands you can also go directly to the default storage, you will be prompted to store the public key file location

Enter the storage directory, open the Id_rsa.pub file, copy the contents, usually start with Ssh-rsa

Open GitHub, sign up/log in to your account, and in the accounts settings, find the SSH and GPG keys settings, click New SSH key, add the previously copied public key to OK

Use the following command to test if you can connect to GitHub

ssh-t [email protected] (if unsuccessful, remove the-t parameter)

If prompted ssh:could not resolve hostname \342\200\223t:name or service not known

Workaround:

SSH-T-P [email protected] (-p means modify server port is 22)

When prompted for input (yes/no), enter Yes at the back.

When you see the Welcome Hi oldinaction! You've successfully authenticated, but GitHub does not provide shell access. The link is successful.

Go to the directory where you want to submit the file, git remote add origin [email protected]:d emo/0915.git ([email protected]:d emo/0915. Git is the SSH address of the project created in GitHub)

Finally execute GIT push-u Origin master, then submit success, view GitHub, you can see the price has been uploaded successfully

How to use Git to upload files to GitHub from this machine

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.