Basic tutorials for using GitHub under Linux systems

Source: Internet
Author: User
Tags commit mkdir ssh

1.

Install git:

The code is as follows:

sudo apt-get install Git-core Git-gui git-doc

2.

To https://github.com/to register an account, a while client login to use.

3.

Install SSH Key on the client to enable us to login securely on the client:

The code is as follows:

CD ~/.ssh

If you are prompted for "no file or directory", then you have not generated SSH key before, skip to step 4th, or save the previous SSH key:

The code is as follows:

Ls

mkdir Key_backup

CP id_rsa* Key_backup

RM Id_rsa

4.

The code is as follows:

Ssh-keygen-t rsa-c "Your_email@youremail.com"

Note: The above to fill in your registered mailbox;

Then ask to save key location, we choose the default, always enter on the

5.

Login Githut, there is a account Settings, point ssh public Key, and then open the 4th step generated id_rsa.pub file, all copied to the Key column, title can be arbitrarily taken, click Add Key;

6.

Then we test the connection:

The code is as follows:

Ssh-t git@github.com

The first time there will be a false hint, do not care about him, enter Yes, then if smooth, there should be "Hi your registered username!" ' ve successfully authenticated, but GitHub does not provide shell access. ' To indicate that the correct connection to the GitHub

7.

The code is as follows:

git config--global user.name "your own name, can not be registered name"

git config--global user.email "your own mailbox, can not be registered mailbox name"

The registered name of git config--global github.user GitHub

git config--global github.token XXX

Note: XXX is obtained in the following way:

Login GitHub, there is an account Settings, click inside the "Account Admin", where the API token that is the above xxx

At this point, we can already use GitHub, the following to create a repository

8.

Open Https://github.com/repositories/new, fill in the project name, description, homepage, etc., click "Create Reopsitory", at this time in our account to create a repository, but it is empty, Here we go to add something:

9.

The code is as follows:

mkdir XXX

(XXX is the folder that you want to sync with github locally)

The code is as follows:

CD XXX

Git init

Touch README

(as an example, we sync the readme here to the repository above)

The code is as follows:

Git and README

Git commit-m ' xxxxxxxxx '

(XXX is the annotation you added for this synchronization to facilitate future tracking)

The code is as follows:

Git remote add Origin git@github.com:xxx/yyy.git

Note: XXX is your github registration name, YYY is the repository name you just created

The code is as follows:

Git push Origin Master

When you are done, you will have the repository in your check in.

10.

Update files

The code is as follows:

VI README

Automatic commit Change file

The code is as follows:

Git commit-a

Update to remote

The code is as follows:

Git push Origin Master

11.

Create and Merge Branches

The code is as follows:

Git branch

Show Current Branch is master

The code is as follows:

Git branch new-feature

Create a branch

The code is as follows:

git checkout new-feature

Switch to New branch

The code is as follows:

VI page_cache.inc.php

The code is as follows:

git add page_cache.inc.php

Commit to local git

The code is as follows:

Git commit-a-M "added initial version of page cache"

Merge to remote server

The code is as follows:

Git push Origin New-feature

If the New-feature branch matures, feel the need to merge into Master

The code is as follows:

git checkout Master

git merge New-feature

Git branch

git push

The New-feature code is also merged in master

Log in to GitHub to see the branching options under Switch branches:

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.