GitHub installation and simple configuration tutorial under Linux

Source: Internet
Author: User
Tags using git version control system

1.GitHub Introduction

Git is a distributed version control system that is relative to a centralized version control system such as CVS and SVN.

Installation of 2.Git

1) Install Git

A. View and use

Under Ubuntu, you can use the following command to see if Git is installed on your system:

$ git

B. Installation

If Git is not already installed on the current system, you can install it under Ubuntu using the following command:

Install Git

2) Register your GitHub account

Enter the GitHub website to register your account, as shown in:

After the registration is completed, be sure to remember to activate the mailbox, otherwise it will affect the subsequent work, can be activated under the settings (Account Settings)->emails.

3) Build warehouse (Repository)

After registering and activating the account, we need to build a warehouse because the private warehouse is paid for, so we choose to create a public repository, as shown in:

Information can be selected and filled according to their actual situation.

3) Generate public key (key)

After we have built a warehouse, we need to add the public key of the computer that can submit the code for this warehouse. Enter the following command on the terminal to check the public key (key) Generation:

$ cd ~/. SSH

If there is a "No such file or directory" type of data, then the public key (key) is missing.

Under the Ubuntu system, there is a ssh-keygen tool that allows us to generate a public key (key) by entering the following command on the terminal:

"[email protected]  

The contents of the quotation marks in the above command need to be changed to their own email address according to their actual situation, such as: [email protected].

The prompt shown shows that the creation is successful, during the generation of the public key, there will be prompts to enter the password and so on, it is recommended that you do not need to enter any information by default, just enter the following:

4) Add public key (key)

Add the public key to the built warehouse, and you can add the public key in the Setup (Account settings)->ssh keys.

A.title try not to use Chinese;

B.key box, view the. Ssh/id_rsa.pub content in the home folder and copy all the text contained therein to the key box;

If "Key is invalid" appears. Ensure you ' ve copied the file correctly "type of error message, just re-execute the third step (that is, generate the public key), regenerate SSH key, and then perform this step to SSH key to add.

At this point, GitHub configuration is complete.

5) Verification

Verify that all of the above configurations are successful by entering the following command in the terminal:

ssh-t [email protected]

During verification, if there is "is you sure want to continue connecting (yes/no)?" prompt, enter "yes", and then enter.

Finally, if "Hi willido!" appears You ' ve successfully authenticated, but GitHub does not provide shell access. " Information, you have successfully connected to GitHub.
6) Set up GitHub

After the success of GitHub, all we have to do is upload the local repository to GitHub, but before we do, we need to set up username and email, because GitHub records them every time it commits.

In the terminal enter the following command to username and email settings:

"Your name""[email protected]"    

Note: After using the--global parameter of the git config command, it means that all the git repositories on the current machine will use this configuration, and of course you can specify a different username and email address for a particular warehouse; This is mainly for the convenience of everyone's contact.

7) Create a repository

A. Creating a directory

Select a suitable place on this machine and create a local directory with the following command:

mkdir directory-name$ cd directory-pwd 

B. Using the Catalog

Enter the directory you created, and then change the directory to a repository that git can manage, with the following command:

$ git init

C. View Warehouse

Enter the local warehouse directory to view the status of the local warehouse directory, as follows:

$ git status

D. Start a git repository remotely

Start a git repository remotely, with the following command:

E. Adding a remote address

Add a remote address, set the warehouse address for GitHub and name it origin (if you can take another name), the command is as follows:

$ git Remote add origin [email protected]:yourname/yourrepo.git

The Yourname and Yourrepo in the previous command indicate your username in GitHub and the name of the repository that you created earlier in GitHub, and then go to. git, open config, where there is a remote "origin" content, This is the remote address you just added, or you can modify config directly to configure the remote address.

F. Adding files

Add some files to the local repository, such as the Readme, command as follows:

$ git Add README

The content you add here must be in the local repository, and the git command needs to be executed in the local repository directory.

G. Submission of comments

Submit the document and comment on the submission, with the following order:

"Your comment" 

H. Uploading Files

Upload the file to the GitHub server with the following command:

$ GIT push origin master

The git push command pushes the contents of the local repository to the remote server.

After modifying the code, use GIT status to see the difference between files, using git add to add files to commit, you can use Git add-i to add files intelligently, git add-a add all files, and then use Git commit to submit this modification Finally, upload to GitHub using git push.

GitHub installation and simple configuration tutorial 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.