Build Git connections to GitHub under Linux

Source: Internet
Author: User
Tags version control system

Git is an open source distributed version control system, and GitHub is a code hosting platform that relies on git.

GitHub leverages Git's extremely powerful cloning and branching capabilities, allowing community members to freely participate in open source projects.

However, before you start learning, you need a GitHub account and a Linux virtual machine that can be networked .

================= preparatory work ==================

First, install Git

  * If you already have Git installed, you can ignore this step

Ubuntu install git: apt-get install git

CentOS install git: yum install git

View git version information: git versions

To configure Git user information:

git config--global"woider"--global"[email Protected]"

↑ Replace the user name and mailbox with your own, type the command after the screen does not output, then the settings are successful

Second, open the SSH service

* If you are using CentOS, SSH is turned on by default, so you can ignore this step

Ubuntu install SSH: apt-get install SSH

View SSH Service Status: ps-e | grep sshd

↑ sshd Indicates that Ssh-server has been started

Third, generate SSH KEY

  * Use the ls-al ~/.ssh command to see if SSH key exists and ignore this step if it exists

Generate SSH KEY: ssh-keygen-t rsa-c "[email protected]"

↑ during SSH key generation, you will be asked to fill in the passphrase, and press ENTER three times to skip.

================SSH KEY===================

First, view SSH KEY

Go to the/root/.ssh directory and view the Id_rsa and id_rsa.pub files:

[Email protected]:~# cd/root/ssh [email protected]:~/.ssh# ls-a

↑id_rsa is the private key, Id_rsa.pub is the public key

Second, copy SSH KEY

Open the Id_rsa.pub file and copy the content to the Clipboard: vim id_rsa.pub

↑ssh key Public key for GITHUB authentication

Third, add SSH KEY

Log on to GitHub, open the Personal Settings page, select the SSH and GPG keys option:

↑title is free to fill in the Key to fill in the content just copied from the Id_rsa.pub

After adding SSH key, Linux can build a local Git connection to GitHub via SSH.

================GitHub===================

First, create a github repository

↑ Create a warehouse called Baidu

↑SSH address is [email protected]:woider/baidu.git

Second, clone the warehouse to the local

To clone a GitHub repository locally via an SSH address:

↑ The first time you connect, you need to confirm that the fingerprint information for GitHub Key is really coming from a github server.

Cloning to a local repository automatically associates the remote repository with the git remote-v command to view the associated state:

↑ Link can be pushed by the git push Origin master command to modify

Note: If you are cloning someone else's repository, you will not be able to push the changes because you do not have permissions.

/*Create a readme.md file*/[email protected]:/home/baidu# vim readme.md/*output readme.md file contents*/[email protected]:/home/baidu# cat readme.md git associated GitHub=============/*to add a file to the staging area*/[email protected]:/home/baidu# git add readme.md/*Submit this modification*/[email protected]:/home/baidu# git commit-m"Add Readme File"[Master 228d321] Add Readme file1File changed,2Insertions (+) Create mode100644readme.md/*push to remote warehouse*/[email protected]:/home/baidu# git push Origin mastercounting objects:3, done.compressing objects: -% (2/2), done. Writing objects: -% (3/3),290bytes |0bytes/s, done. Total3(Delta0), reused0(Delta0) to [email Protected]:woider/baidu.git 36c5c1c. 228d321 Master-Master[email protected]:/home/baidu#

Build Git connections to GitHub under Linux

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.