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've already installed Git, 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 user.name "xxxxxxx" Git config--global user.email "[Email protected]"
Replace the user name and mailbox with your own, type the command after the screen does not output, it means that the setting is 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 is 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]"

Generate SSH key process, will let you fill in the passphrase, double-press three times the carriage return skips

==================================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 can be filled in, 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 named Baidu

SSH address is [email protected]:xxxxx/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:

The link can be pushed through the GIT push Origin master command to push the modification

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# C At readme.md git affiliate github=============/* add file to Staging area */[email protected]:/home/baidu# git add readme.md/* Submit this modification */[email PR otected]:/home/baidu# git commit-m "Add Readme file" [Master 228d321] Add Readme file 1 file changed, 2 insertions (+) Crea Te mode 100644 readme.md/  * push to remote repository */[email protected]:/home/baidu# git push Origin mastercounting objects:3, done.c Ompressing objects:100% (2/2), done. Writing objects:100% (3/3), 290 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (Delta 0) to [email protected]:xxxxx/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.