Build a github environment and push pull code under Linux

Source: Internet
Author: User

First, the preparatory work

1. There is a GitHub account, please go to github.com to register

2. Git is already installed

Check to see if Git is installed with the following command

$ git--version   # # #检查是否安装了git, if not installed, execute the next command $ sudo apt-get install git    # # #安装git的命令
Second, build the GitHub environment

1. command to generate SSH key public key

$ ssh-keygen-t Rsa-c "your email address"  

# # #比如我的邮箱是 [email protected], then this command is $ ssh-keygen-t rsa-c "[Email protected]"

2. Login to GitHub and enter the SSH key public key

3. Test if SSH key is successful

$ ssh-t [email protected]

4.git Configuration

$ git config--global user.name "your name" $ git config--global user.email "your email"
Third, from GitHub's repository clone project to local and upload local projects to GitHub

Why do I have to put these two pieces together to write, because I was in the first contact with GitHub when the content of this part is blurred! The average user is just using HTTPS to clone someone else's library locally, because he is not the owner and administrator of the project, and what I'm saying here is that you create your own repository on GitHub.

1. What are the ways to get to the local clone project from GitHub?

https://help.github.com/articles/which-remote-url-should-i-use/This article is a good illustration of how you can use it.

A total of three ways: HTTPS, SSH, subversion. The most recommended use of the first HTTPS

Use HTTPS to clone

This method can be used for all public and private warehouses, depending on your permissions on the repository, can provide you with read-only or read-write access capabilities. When you want to operate fetch,pull,push to a remote repository, you need to fill in your GitHub username and password.

Copy the HTTPS URL use the following command to clone the project to a local

$ git clone https://github.com/your name/your repo. git

Note: The above command red text your name is your github account name, your repo is the name of the clone project you want to

Use SSH to clone

With SSH you have to generate an SSH key pair on your computer and add this key to your GitHub account.

Copy the SSH URL and use the following command

$ git clone [email protected]:your name/your repo. git
using Subversion

This is what we call SVN, which is not explained in detail.

2. Upload an existing project from a local upload project to GitHub

As above, clone your existing project directly from GitHub to local, edit the item on your computer, upload it to GitHub, and use the following command

$ git add *  # # #如有新添加的文件执行此行, add all the files $ git commit-m "Enter the text you submitted this time" $ Git push-u origin Master

  

The newly created project

Create a new warehouse on GitHub, assuming named Test, and then add a description to the project, the default selection of public, the following initialization repository you can choose not to choose

If there is no choice, initialize the repository with a command.

echo # Hello >> readme.md   # # #在项目根目录下创建一个README. md file and enter the content "# hello" git init # # #初始化git Add readme.md # # # Add a newly created file git commit-m "first commit" # #提交 git remote add origin [email protected]:floraluo/aaa.gitgit push-u Ori Gin Master

  

Build a github environment and push pull code under Linux

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.