Initial use of git and GitHub

Source: Internet
Author: User
Tags git client website hosting
Reprinted please note source http://hi.baidu.com/kissdev/blog/item/944aa2fab2817215a8d311f1.html

1. Git

Compared with CVS/SVN, git has the following advantages:
-Supports offline development and offline Repository
-Powerful Branch functions, suitable for collaboration between multiple independent developers
-Speed Block

For more details, see http://mgcore.com/viewthread.php? Tid = 15556

Git User Guide http://www.linuxgem.org/user_files/linuxgem/Image/git-tutor.pdf

2. GitHub

GitHub is a website hosting git (open-source or closed-source) projects. It charges fees for closed-source projects. The minimum fee is GB for free starting from 7 $/month. The price list is as follows:

Steps for using GitHub:
1. Apply for a GitHub account XXX and create a new repository named new-project.

2. Install the GIT client (Linux)
# Yum install git Git-Gui

3. Generate a key pair so that the project can be pushed to GitHub.
# Ssh-keygen-t rsa-c "xxx@gmail.com"
4. Copy. Ssh/id_rsa.pub to the GitHub website.

5. For convenience, set SSH without entering a password
# Eval 'ssh-agent'
# Ssh-add
(Input passphrase)

6. Test whether GitHub can be connected
# SSH git@github.com
If the configuration is correct
Error: Hi XXX! You 've successfully authenticated, but GitHub does not provide shell access
Connection to github.com closed.

7. Set git global user configuration
# Git config -- global user. Name "XXX"
# Git config -- global user. Email xxx@gmail.com

8. Create a new local project work tree
# Mkdir New-Project
# Cd New-Project
# Git init
# Touch readme
# Git add readme
# Git commit-m'first commit'
Define Remote Server alias Origin
# Git remote add origin git@github.com: xxx/new-project.git
Local and remote merge. The local default branch is master.
# Git push origin master

GitHub site can see, http://github.com/xxx/new-project

9. Update files
# Vi readme
Automatic commit to change files
# Git commit-
Update to remote
# Git push origin master

10. Create and merge branches
# Git branch: displays that the current branch is a master node.
# Git Branch New-feature create Branch
# Switch git checkout New-feature to the new branch
# Vi page_cache.inc.php
# Git add page_cache.inc.php
Commit to local git
# Git commit-a-m "added initial version of page cache"
Merge to remote server
# Git push origin New-feature

If the new-feature branch is mature, it is necessary to merge it into the master
# Git checkout master
# Git merge New-feature
# Git Branch
# Git push
The new-feature code is also merged in the master.

After logging on to GitHub, you can see the branch options under "Switch branches:

GitHub also has a very useful function to view the network of the development process ):

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.