Use Ubuntu Linux GitHub & git

Source: Internet
Author: User
Tags git commands

 

GitHub user guide! (For Linux systems, UBUNTU systems)

Step 1: download and install git.

Use Synaptic Package Manager to install the latest version of git. We recommend that you install Git-core, Git-Gui, and git-Doc.

Step 2: Set SSH keys

GitHub uses SSH keys to ensure secure connection between your computer and GitHub. The setting process is simple.

But there are several steps.

Step 1: Check the existing SSH keys.

$ Cd ~ /. SSH

If the prompt says there is no such file or directory. (No such file or directory), skip to step 3. Otherwise, continue.

Step 2: Back up existing SSH keys.

Step 3: generate a new SSH key.

My production process is as follows:

Banxi1988 @ banxi :~ $ Ssh-keygen-t rsa-c "banxi1988@gmail.com"

Generating public/private RSA key pair.

Enter file in which to save the key (/home/banxi1988/. Ssh/id_rsa ):

Enter passphrase (empty for no passphrase ):

Enter same passphrase again:

Passphrases do not match. Try again.

Enter passphrase (empty for no passphrase ):

Enter same passphrase again:

Your identification has been saved in/home/banxi1988/. Ssh/id_rsa.

Your public key has been saved in/home/banxi1988/. Ssh/id_rsa.pub.

The key fingerprint is:

0C: A5: 4d: A7: D8: E8: 42: B2: 5C: 75: D0: 4C: E5: FF: 6a: 7f
Banxi1988@gmail.com

The key's randomart image is:

+ -- [RSA 2048] ---- +

| O =. o |

|. XO + |

|. O = +. |

|. =. O. |

| O. S. |

|... |

|. |

|. E |

| ...... |

+ ----------------- +

Banxi1988 @ banxi :~ $

Step 4:

Click account settings in GitHub. Click the SSH public key and add another public key.

Open the previously generated id_rsa.pub file. (You may need to show hidden files before they can be viewed and opened in gedit or another editor.

Do not edit, add spaces or line breaks .)

Copy and paste the content to the key input column below.

Step 5: test it.

Banxi1988 @ banxi :~ $ SSH
Git@github.com

/Etc/ssh/ssh_config: line 20: Bad configuration option: x11forwrding

/Etc/ssh/ssh_config: terminating, 1 bad configuration options

Banxi1988 @ banxi :~ $

After modify the ssh_config. The passphrase entered above is required.

Banxi1988 @ banxi :~ $ SSH
Git@github.com

The authenticity of host 'github. com (207.97.227.239) 'can't be established.

RSA key fingerprint is 16: 27: AC: A5: 76: 28: 2D: 36: 63: 1b: 56: 4d: EB: DF: A6: 48.

Are you sure you want to continue connecting (Yes/No )? Yes

Warning: Permanently added 'github. com, 207.97.227.239 '(RSA) to the list of known hosts.

Pty allocation request failed on channel 0

Hi banxi1988! You 've successfully authenticated, but GitHub does not provide shell access.

Connection to github.com closed.

Banxi1988 @ banxi :~ $

 

Step 6: Set git's personal information.

1. Set the user name and email. Git uses this to verify each submitter. In addition, GitHub will use this information to contact your GitHub account. The following name should be your real name. Instead of the GitHub user name.

Banxi1988 @ banxi :~ $ Git config -- global user. Name "Li haizhen"

Banxi1988 @ banxi :~ $ Git config -- global user. Email "banxi1988@gmail.com"

Banxi1988 @ banxi :~ $

2. Set the GitHub command ring.

Some tools do not use SSH for connection. To use these tools. You should find out how to configure your API token.

Click on GitHub. Account settings, and then click Account admin ).

In the API token column, you have your API token.

Run the following code in the command line.

Banxi1988 @ banxi :~ $ Git config -- Global GitHub. User banxi1988

Banxi1988 @ banxi :~ $ Git config -- Global GitHub. Token e5ebe68d43d9820ed8d05a3d2633d7f3

Banxi1988 @ banxi :~ $

The above user refers to the GitHub user name.

Finally, congratulations! You have set git and GitHub correctly.

Next. All you need to do is. 1. Create a repository. 2. Fork a repository. 3. Community.

 

Section 2: Create a repo Repositories)

After logging on to the github.com homepage, you can see that there are four steps in the following column to create repository.

Enter the project name directly. You can leave other items empty. You need to fill in the form. This form is also self-explanatory.

After creation, a page is displayed, indicating how to proceed.

As follows:

Git@github.com: banxi1988/tastehibernate. Git

 
Next, create a basic readme file for your project.

The detailed procedure is as follows:

Global setup:
Download and install git
Git config -- global user. Name "banxi1988"
Git config -- global user. Email banxi1988@gmail.com
Next steps:
Mkdir tastehibernate
CD tastehibernate
Git init
Touch readme
Git add readme
Git commit-m'first commit'
Git remote add Origin
Git@github.com: banxi1988/tastehibernate. Git
Git push-u origin master
Existing git Repo?
CD existing_git_repo
Git remote add Origin
Git@github.com: banxi1988/tastehibernate. Git
Git push-u origin master
Importing a subversion Repo?
Click here
When you're done:
Continue

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ git init

Initialized empty git repository in/home/banxi1988/GitHub/tastehibernate/. Git/

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ touch readme

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ VI readme

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ git add readme

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ git commit-m'first commit'

[Master (root-commit) 6ec8aae] First Commit

1 files changed, 6 insertions (+), 0 deletions (-)

Create mode 100644 readme

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ git remote add Origin
Git@github.com: banxi1988/tastehibernate. Git

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ git push origin master

Error: banxi1988/tastehibernate. Git doesn't exist. Did you enter it correctly?

Fatal: the remote end hung up unexpectedly

Banxi1988 @ banxi :~ /GitHub/tastehibernate $ git push-u origin master

Counting objects: 3, done.

Delta compression using up to 2 threads.

Compressing objects: 100% (2/2), done.

Writing objects: 100% (3/3), 383 bytes, done.

Total 3 (delta 0), reused 0 (delta 0)

To git@github.com: banxi1988/tastehibernate. Git

* [New branch] Master-> master

Branch master set up to track remote branch master from origin.

Banxi1988 @ banxi :~ /GitHub/tastehibernate $

 

For more information about git commands, see the GIT manual.

Now we can create a library, create a file, submit it, and push it to GitHub. What will we do next?

Section 3: fork a repo

Sometimes you find that you want to contribute to others' projects or use others' projects as your starting point.
 
Fork is a project. on the homepage of the project you want to fork, find the fork button. Click.

Next, set your local repository.

A. Clone the project.

$ Git clone git@github.com: username/projectname. Git

B. Remote Configuration.

After you clone a project. it has a default remote. it is called. origin. this means that you fork on GitHub. instead of in the original warehouse. to track the original repository, you need to add another option called upstream.

$ CD projectname

$ Git remote add upstream git: // github.com/username/projectname.git

$ Git fetch upstream

 
 
Next, what you need to do is.

A. Push and submit.

Once you make some commits to your fork warehouse, you may want to push them to your fork project. You have to do the same as the normal project.

$ Git push origin master

 
Receives upstream changes.

If the original repository of fork has changed, you can use the following command to update your fork to the local repository.

$ Git fetch upstream

$ Git merge upstream/Master

For more instructions, see related documents, such as creating branches.

 

This guide was translated by banxi1988 Based on the help provided by GitHub.

Due to my limited level, the translation is not good. You can give me some comments or go directly to GitHub to see help.

 

 

Reference link:

Http://blog.chinaunix.net/uid-26185912-id-3327885.html

 

Http://www.th7.cn/system/lin/2012/06/04/23044.shtml

 

Http://luozhaoyu.iteye.com/blog/1461705

 

Http://blog.chinaunix.net/uid-25885064-id-2747803.html

Related Article

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.