git pushes small white tutorials to GitHub

Source: Internet
Author: User
Tags commit config ssh using git

If you are a programmer, you do not know git and GitHub, it means you are low;

git: Distributed version management tools, specifically I am not here to Wikipedia, since all to start using git, I am sure what git is, what you can do to have a certain understanding;

Learn and use a period of time git, think of their own rough in the beginning of the dark, thinking of git to GitHub push the introduction of the use of writing down, hope can help everyone, of course, have to recommend Liao Shin (Liao Xuefeng great god git tutorial, easy to understand, everyone to see);

Note: I'm talking about Windows platform-based

First step : Download git download address: Https://git-for-windows.github.io

Step two : Find Git in the Start menu and open the Gitbash

A page that looks like a Linux terminal will appear when you open it:

This time we enter a git to try: There will be a lot of hints, you can see (of course, you can read the premise of English)

Step three: set up our information: Enter the command separately

$ git config–global user.name "Your name"

* * Note: is to enter your own name and mailbox, the name can be arbitrary

$ git config–global user.email "email@example.com"

Fourth Step : Create a repository, white point, is to find a suitable place on our computer, create a folder test (name casually, see what you need), you can also create a folder directly in the Gitbash:

$ mkdir    Test

Create a folder in the current directory test, go to this folder

$ CD Test

( If you create a folder in your own location on your computer, remember to enter the absolute path, otherwise you can't find it.)

Then enter the following command to initialize the repository

$ git init

For example, to create a test folder on your desktop, the command you need to enter in Gitbash is:

Note: My current directory is on the desktop ... Tip We have created success.

For example, to create the test directory under Gitbash, the following commands are:

This Test folder is really the local repository of Git ;

Fifth Step : Submit file to Repository

Here we can first add a file to try. (Same as manual add and command Add)

$ vim Readme.txt

You can quit anything without editing (if you do not command, manually add it)

And then:

$ git Add readme.txt

What hints are not, the description is good, that who seems to have said, no hint on everything is good.

The operation of this command is to add Readme.txt from the workspace to the repository, the point is the repository of staging area;

In fact, the repository is divided into the staging area (stage) and the Master branch, here I will simply explain, want to learn more about the students can go to Liao Xuefeng great God's official online look;

Then execute:

$ git commit-m "additional instructions"

The command is to add the Readme.txt file to the Master branch and append the additional instructions you want;

After the execution of these two commands, the Readme.txt file is formally added to the repository;

Sixth step : go to the GitHub website to register an account

I'm going to omit this step.
Registration Tutorial : http://jingyan.baidu.com/article/455a9950abe0ada167277864.html

Seventh Step : Connect to Git and GitHub

Because Git and GitHub are connected via SSH keys, to ensure that the code is uploaded by you, is a protection measure;

So, first locate the. SSH directory in your git home directory, which has two text:
Id_rsa and Id_rsa.pub

Where Id_rsa is your private key, and we want to use the content of id_rsa.pub This file, open this text, which is your public key ssh, copy the contents;

Into your github, avatar that piece has a drop-down menu, click on the settings

On the left side of this page is a list of options to find the SSH and .... Click
A page will appear, allowing you to add a new SSH, where the title can be arbitrarily named,
Paste the ssh that you just copied into the bottom text box, and then click Add SSH key;

We have successfully connected to the local;

Eighth step : Push from local to remote

Okay, here's the play, how to connect to GitHub's remote repository and the local repository, of course, now you don't have a remote repository;

Create a remote repository: On the GitHub page there is a plus sign "+" on the top right, mouse over click, there will be a drop-down menu, select New Repository, and then click:

Some basic settings for the new warehouse

When the new warehouse is set up, it will go to the following page and assign the SSH of the warehouse

There are two optional operations in the next, one is to clone a remote repository locally, one is to build a local warehouse, direct and this remote warehouse connection , I choose the second type:

At first, we did not build a local library of test locally, and now continue to operate in this library:

After entering the test, enter the command: Git remote add origin (SSH of the remote library just copied)

Note: Here to enter your own remote library of SSH

Now the local library and the remote library are connected;
We can edit a file learngit.txt add to the local library, submit to the Branch master, and then start to push to the remote library;

Enter the command in turn:

Vimlearngit.txt (not vim can be manually added, as previously said) Vim Learngit.txt (not vim can be manually added, previously discussed) git add learngit.txt gitcommit−m "Firstcommit" Git commit-m "First commit" (first commit) Git push-u Origin master (push to remote repository)

- u This parameter is used for the first push and can be ignored the next time it is used

The first time you add a warning, waring can be ignored.

Some students sometimes encounter a mistake: error; What
It is possible to set up a remote library by default when a readme.md file is generated, do not panic,
You enter a command here:

$git Pull–rebase Origin Master

Don't ask me what this command means, if you want to study deeply, check it yourself.

Next we can refresh the test library on GitHub to see

As you can see, learngit.txt already exists, so it's done.

Finally, if you feel that adding files in the future is complicated by commands, you can actually add them directly on GitHub, and after you click on the test library, there is a green button at the bottom right (add
A README) can be clicked, directly edit the file to add.

After each submission, github your page will have a form to show your submission, and the different depth of green represents how much you submit the file, the effect is as follows:

Git to GitHub's push small white tutorial is here, the literary talent is not very good, I hope you forgive me.

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.