Go GitHub configuration

Source: Internet
Author: User
Tags git client

The following transfers from http://liuzhijun.iteye.com/blog/1457207

If you have any questions please contact me to delete.

-----————————————————————————

If your code doesn't know where to put it, putting it on GitHub is a good choice. The following is an introductory level configuration article. (The following configurations apply to both Windows and Linux)

After GitHub is registered, first create a warehouse (Repositry), on your personal page to the right "Your repositories" module, click on the New repository, here we fill out project name as "test"

In addition to the item name is required, the other two blanks are optional. After clicking "Create Repository", you will see this page:

That's what you're going to do next. First you want to install the Git client, Windows version, the installation when prompted to choose the next line, after installation is set SSH Keys

Open the installation directory and go to the GIT bash console

1, check whether there is SSH keys, if the first installation is not, enter the command (here the command Input method basic and under Linux is the same), if there is a key, you can skip to the 4th step. (The following $ symbol is the beginning of the command line and does not need to be entered manually)

Note: The user directory in Linux may not have a. SSH directory that needs to be created yourself

Java code
    1. $ CD ~/.ssh

If "No such file or directory" is displayed then go straight to step 3rd, otherwise perform step 2nd (this means that if there is no. ssh directory, we are going to create one, if it exists, we will back up the existing)

2. Backup, remove the existing SSH keys

Java code
    1. $ ls
    2. $ mkdir Key_backup
    3. $ CP id_rsa* Key_backup
    4. $ RM id_rsa*

(Back up files that start with id_rsa* to the Key_backup) file, removing the files from the current directory

3. Generate a new SSH Key

Java code
    1. $ ssh-keygen-t rsa-c "[email protected]"

Note: If you are prompted with error Could not create directory '//.ssh ', you need to set the environment variable "Home"---> "Your home directory", I am here to set the home----->users/ Cloudview, I am surprised to see this error, do not know whether the installation of other software causes the system environment variable changes or other reasons, unknown origin?

(The above email is the email address you registered, note that double quotation marks can not be omitted, prompt to enter the file name to save key is, the default press ENTER on the line, the system is the default way to save, then back to the prompt to enter a "passphrases" thing, Can simply understand the local machine and GitHub to communicate with the credentials, equivalent to the password, but more complex than the password, but also more secure, this to remember, later to use

Finally you will see (fingerprint) A string of 16 binary digits, while generating the Id_rsa.pub file under the current path. SSH. Description Key has been generated

4. Add the key you just generated to GitHub

Click on the GitHub site account Setting > SSH keys >add ssh key, not clear can see

Open the Id_rsa.pub file with the editor (Notepad++,vim) and select all the contents to be copied into the input box of key. This will add the key to the success.

At this time the success is not far away, one step test. Enter the following command

Java code
    1. $ ssh-t git@github. com

If you are prompted to continue the connection, yes, you will see the following message stating that you are done.

Wrote hi "username"! You ' re successfully authentiated,but GitHub does not provide shell access

Don't worry, although you can connect successfully, but do not know how to upload files to GitHub, then to try.

5. Uploading files to GitHub

First set up personal information, used in the submission code is to explain who submitted, and then you can use email to contact him.

Java code
    1. $ git config--global user.name "Firstname Lastname"
    2. $ git config--global user.email "[email protected]"

The name above is usually your real name.

Next, execute the following command

Java code
    1. mkdir test
    2. CD test
    3. Git init
    4. Touch README
    5. git add README
    6. git commit-m ' first commit '
    7. Git remote add origin git@github. Com:lzjun/test.git
    8. Git push-u Origin Master

Probably means to create a local test directory, initialize, create a Readme file, of course, this file space-time, you can fill in the content. The next step is to add the Readme file into the GIT management scope,

Commit: It's equivalent to taking a snapshot of your project's code, files, and everything (like we take photos), all of which are fixed at this moment, and each commit will only take a snapshot of the files that have changed. There's no code submitted to github at this point.

Remote: Connect to GitHub, and note that the "Lzjun" Here is my account name, which is changed according to your name. This step only appears the first time you submit the file, and you want to enter the previous pressphrases.

Push: It's a good idea to push files to the GitHub site.

The following error may occur during push: to [email protected]:lzjun/test.git
! [Rejected] master, master (Non-fast-forward)
Error:failed to push some refs to ' [email protected]:lzjun/test.git '
To prevent-losing history, Non-fast-forward updates were rejected
Merge the remote changes (e.g. ' git pull ') before pushing again. See the
' Note about Fast-forwards ' sections of ' git push--help ' for details.

You can pull it over first.

git pull [email protected]:lzjun/importnewstat.git master

Quickly open the GitHub site and see if you have a Readme file in your test repository.

6. If you fork someone else's project

If you want to download a project named username user, we need to use the Clone command, assuming the project is called "Tools"

Java code
    1. git clone git@github. Com:username/tools.git

Add: If the commit is garbled: can be added the following settings

Java code
    1. git config--global i18n.commitencoding utf-8

Reference: http://help.github.com/fork-a-repo/, image from the site.

Go GitHub configuration

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.