Git installation has been connected to GitHub

Source: Internet
Author: User
Tags ftp transfer


Https://help.github.com/articles/generating-ssh-keys

1. Install git

[Plain]View
Plaincopy

  1. Sudo apt-Get install Git-core Git-Gui Git-Doc


2. Set the SSH key. Git connects to GitHub through SSH (an encrypted file similar to the FTP Transfer Protocol)

Back up the original key first

[Plain]View
Plaincopy

  1. Cd ~ //. Ssh // enter the. Ssh directory (hide the directory LS-lH)
  2. $ Ls // list all files in the. Ssh directory
  3. $ Mkdir key_backup // create a directory for backup
  4. $ CP id_rsa * key_backup // copy the original key from the. Ssh directory to the backup directory.
  5. $ RM id_rsa * // Delete the original key


Create a new SSH key

[Plain]View
Plaincopy

  1. $ Ssh-keygen-t rsa-c "your_email@youremail.com"


When you run this command, the system prompts the file storage path, press ENTER

Then you are prompted to enter passphrase (password) and enter twice (you can enter twice without entering)

Two files are generated in the. Ssh Directory: id_rsa and id_rsa.pub.

3. Add an SSH key to GitHub

On the GitHub site click
"Account settings"> click "ssh"
Keys "> click" add SSH key"

Click the wrench icon in the upper right corner, click the SSH key in the left menu, and then add SSH key on the right page

Use Kate or another text editor to open the id_rsa.puh file and copy all the characters in it. (do not use VI here. If you use the key copied by VI, an invalid key is prompted, which is probably caused by line breaks)

Paste the copied key into the GitHub key. The title is optional. Click "add key" to display the "invalid key prompt (in English)". If passphrase is entered earlier, a prompt is displayed.

4. Test SSH link GitHub

[Plain]View
Plaincopy

  1. $ Ssh-T git@github.com // just enter that, don't change

The prompt successfully is OK.

5. Set your own git Information

[Plain]View
Plaincopy

  1. $ Git config -- global user. Name "firstname lastname" sets the name of the user for all git instances on the System
  2. $ Git config -- global user. Email "your_email@youremail.com"


6. Use of Git

// Assume that the existing project directory is submitted

CD dirname: Enter the project directory

Git init git Initialization

Git Add. There is a "." behind it to add the current directory.

Git commit-M "commit first time" Local commit

// Items starting from 0

Mkdir projectname: Create a folder

CD projectname to enter the folder

Git init git Initialization

Touch readme to create a ReadMe file

Git add readme file

Git commit-M "Commit file readme" Submit

7. GitHub settings

At your Repositories on the GitHub Homepage
Click "new repository" and enter the name and description. Select "private" or "public" to create a repository (repository)

Enter the repository to view the code, newwork, wiki, and other menus. There are three links under the menu: SSH/HTTP/git only, and copy the SSH address.

[Plain]View
Plaincopy

  1. $ Git remote add origin git@github.com: username/Hello-World.gitSets the origin for the hello-world repo // enter the address you just copied here
  2. $ Git push-u origin master

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.