Https://help.github.com/articles/generating-ssh-keys
1. Install git
[Plain]View
Plaincopy
- 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
- Cd ~ //. Ssh // enter the. Ssh directory (hide the directory LS-lH)
- $ Ls // list all files in the. Ssh directory
- $ Mkdir key_backup // create a directory for backup
- $ CP id_rsa * key_backup // copy the original key from the. Ssh directory to the backup directory.
- $ RM id_rsa * // Delete the original key
Create a new SSH key
[Plain]View
Plaincopy
- $ 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
- $ 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
- $ Git config -- global user. Name "firstname lastname" sets the name of the user for all git instances on the System
- $ 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
- $ 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
- $ Git push-u origin master