GitHub simple Hands-on tutorial (beginner's note)

Source: Internet
Author: User

This tutorial is written by the novice, but also just learn to use a little fur introduced to everyone, do not like to see.

This article features a beginner's perspective to share their understanding and experience, but at the same time will bring the consequences of possible errors. It doesn't matter, it doesn't affect your initial application to GitHub. Let's start with a hands-on tutorial

First, the basic introduction

Git is the latest version control tool, better than CVS, SVN or anything else.

Github.com is a Web site that provides you with a remote repository (where your work with your collaborators is ultimately presented here), and it is also a shared platform where you can find countless sources.

Second, the use of the process

1. Register your GitHub account.

Log in to http://github.com and have your own account number and password.

2. Download a git client.

recommended msysgit,:http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git; Download the latest version.

3, install Msysgit.

All the way to the default point next, the installation is complete.

4. Bind your GitHub account and mail.

Click on the Msysgit shortcut to bring up a command line shell, enter:

git config--global user.name "yourname"

(The yourname here is equivalent to one of your signatures, not the GitHub login name.) You will have this signature in the future documents you submit)

Continue entering after carriage return:

git config--global user.email "[Email protected]"

(Your GitHub account email is entered here)

5, set up ssh.

SSH is a way to connect, on the one hand, to avoid you always enter the user and password when connecting, on the other hand increase security. My first contact with SSH, my simple understanding is that SSH is two long strings, one is a lock, the other is the key. You put the lock on your GitHub account, and your keys are on your computer, and git automatically unlocks the keys whenever you connect.

First step: Generate Keys and locks

On the command line input: ssh-keygen-t rsa-c [email protected]

Then enter, the period will ask you to generate the file name and passphrase, for my rookie, I went all the way to the return. If you are a rookie, do as I do.

Step two: Put the lock on GitHub's account

The files that were generated in the previous step are placed in the c:/users/user name (your Windows user)/.ssh/folder, and the Id_rsa.pub file is opened with Notepad, and all the contents are copied. Sign in to the GitHub website, find account setting,

Paste the copy you just copied into the Key text box.

Step three: Test for success

On the command line input: ssh-t [email protected] If successful, a welcome character is displayed.

6. Create a remote library (repository)

Sign in to your GitHub account on the website, click on the Repositoies tab, click New,

Create a library called Hello. (name is random, but you must use the same name when you build the library locally.)

7. Create a local library

In any folder on your computer, create a new directory with the same name as the one you built on GitHub, and here is hello. Then right-click on the folder, select Git bash in the pop-up menu, pop up the command line window, type: Git init. At this point git will create a hidden directory under this folder, which is the local library. , and this Hello directory is actually your working path.

8. Bind to the repository and remote library

Take the 7th step (that is, your directory as shown in the command line is Hello) and enter the command:

git remote add origin [email protected]: your username/hello.git

8. Start syncing

1) Update the local library data from the remote library

OK, now your work path-local library-remote libraries are all in tandem. Now we can synchronize the data. First of all, we built a remote library when the seemingly established a readme file, at that time, it does not matter, but we want to ensure that the local and remote libraries consistent, and the remote Library is the final version, so first ensure that the local library and remote library files. Under Work path (that is, Git displays your Hello folder) input: Git pull Origin master, if the remote library has a file that your local library does not have, git will download it for you, otherwise it shows already update.

The pull and Origin here are good to understand, what does master mean? It is the main branch of the meaning, about the branch we do not discuss, you just know that a library can have multiple branches, currently we only master a branch.

2) Submit local new data to the remote library

If you want to add a New.java file to the remote library Hello

The first step: Copy the New.java to the local Hello folder.

Step two: Under the hello path of the command line, enter:

git add New.java (the local repository knows this file)

Step Three: Enter:

Git commit-m "I submitted a java." (changes submitted to a local library) here-m means that a message is submitted, followed by the message content, which is required.

Fourth Step: Enter:

Git push origin Master (changes submitted to remote library)

OK, get it done. You log in to your account on the GitHub website and you will find a file with more

3) Update all changes to the local file to the remote library

In general, you don't know how much your file has changed, you can enter Git status, tell you what's changed, and then you enter Git commit-a-m "Your message", commit all the changes to the local repository, continue GIT push origin Master, it is updated to the remote library.

Note: General changes do not push, only the final feeling is almost, and then push the file up.

9. Clone someone else's library

The first step:

First, go to someone else's library on the site (via links provided by others or by yourself on the page), then select SSH at the bottom right,

Copy the link down.

Second, create a new folder on your computer with the same name, then right-click on the folder, select Git bash in the pop-up menu, open the command line, enter GIT init, initialize the library, then enter GIT remote add origin, right-click the command-line window title bar, In the pop-up menu, select "Edit", "paste", enter, the connection was established.

The third step, enter Git clone, just wait for it to help you finish.

Note: If the other party is not authorized, you will not be able to push. Your own library can also be delegated to others, there is a setting on the right of your library page, you can set Collabtories (collaborator).

The above is my initial understanding, there must be a wrong place, later found will come to change. Thank you.

GitHub simple Hands-on tutorial (beginner's note)

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.