"Git" Install and first use git and github fool tutorial

Source: Internet
Author: User

Previously useful, but relatively few, this brother hope our project code is uploaded to GitHub, the new brother will not use GitHub, let me give science, let them get started. Just as I just reinstall the system, the process of installing git from scratch and the first push code to GitHub is recorded:

1. Download and install git (windows7)

Download Git:https://www.git-scm.com/download/win

Click on the exe file to go all the way next.

2. Configuration (reference: Http://git.oschina.net/progit/1-%E8%B5%B7%E6%AD%A5.html#1.4-%E5%AE%89%E8%A3%85-Git)

GIT provides a tool called Git config, which is actually a git-config command, but you can git call this command by adding a name. ), designed to configure or read the appropriate working environment variables

(Forget, I was based on the tutorial configured these three, the last Difference analysis tool I do not understand, no Tube = =| | | )

$git config--global"yourname"--global"[email Protected]"--global user.editor yourdeitor

3. Create a local library in an existing folder (or you do not want to create a new empty folder in an existing folder)

The first step is to switch to the folder you want to build. Note that the folder path must be double-slash!

$ cd e:\\4. codes\\ccode\\oj_leetcode$ git init

This will be OK, then go to that folder to see, you should see a. git folder, (unless you hide

4. Upload the local file (first understand the three states of Git internal files):

$ git add filename//Put file in staging area

$ git commit-m "prompt info"//push files from the staging area to the Git local repository

The local repository is built to be available, and the basic version control requirements can be achieved, but how can I push my code onto GitHub and need to connect the local library with the libraries on GitHub:

5. Create and copy SSH key

If you are not currently in the home directory, you will need to switch to the home directory first:

$ cd

  

Because the transfer between the local git repository and the GitHub repository is encrypted via SSH, you first have to have your own SSH key and then put it on GitHub.

First check if there is an SSH key locally, go to the home directory to see if there is an. ssh file, and. SSH has RSA files, if not:

$ ssh-keygen-t rsa-c "Youremail"

Then go all the way next to see the home directory, you should already have. ssh files, this time you can copy the contents of Id_rsa.pub to GitHub, but I can't open the pub file, just use the command line to copy

$ clip < ~/.ssh/id_rsa.pub (if you can open the pub file and copy the content manually, you don't have to use this command)

  

6. Add SSH key to GitHub

First step: Find settings in the upper right corner.

  

Step two, click SSH and GPG keys, then New SSH key

  

The third step: in the title to take a name, paste the previously copied pub file content in the area below the key.

Now that I have successfully added my SSH key to GitHub, I can connect the local library to the library on GitHub:

7. Create a new library on GitHub, then copy the new library's SSH, connect to the local library and the GitHub Remote library:

  

A new library interface will then appear:

  

Copy the SSH address in the red box and connect to the local library:

You need the CD current directory to the local library directory, and then enter the command in the local library directory:

$ git Remote add origin Yourssh

  

Now that you've connected your local repository to GitHub, you're free to push local content to GitHub.

The first push (and then push will not have to add-u):

$ Git push-u Origin master (this is the first push, after which push is not added-u)

  

OK ~

"Git" Install and first use git and github fool tutorial

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.