Using GIT commands and GitHub projects under Linux

Source: Internet
Author: User
Tags using git git commands

Build a git environment under Linux
1. Create a GitHub account, https://github.com
2, Linux create SSH key:

[Plain]View Plaincopy
    1. Ssh-keygen # #一直默认就可以了

3. Add the public key to the GitHub account information accounts settings->ssh key
4. Test verification is successful.

[Plain]View Plaincopy
    1. ssh-t [email protected]
    2. Hi someone! You've successfully authenticated, but GitHub does not provide shell access.


Sync GitHub to Local
1. Copy the project to Local:

[Plain]View Plaincopy
    1. git clone git://github.com:xxxx/test.git # #以gitreadonly方式克隆到本地, can only read
    2. git clone [email protected]:xxx/test.git # #以SSH方式克隆到本地, can read and write
    3. git clone https://github.com/xxx/test.git # #以https方式克隆到本地, can read and write
    4. git fetch [email protected]:xxx/xxx.git # #获取到本地但不合并
    5. git pull [email protected]:xxx/xxx.git # #获取并合并内容到本地


Submit a project locally to GitHub
1. Local Configuration

[Plain]View Plaincopy
    1. git config--global user.name ' Onovps '
    2. git config--global user.email ' [email protected] ' #全局联系方式, optional

2. Create a new Git project and submit it to GitHub.

[Plain]View Plaincopy
    1. mkdir TestDir & CD TestDir
    2. Touch readme.md
    3. Git init #初始化一个本地库
    4. git add readme.md #添加文件到本地仓库
    5. git rm readme.md #本地倒库内删除
    6. Git commit-m "First commit" #提交到本地库并备注, at which time the change is still local.
    7. Git commit-a # #自动更新变化的文件, a can be understood as auto
    8. git remote add xxx [email protected]:xxx/xxx.git #增加一个远程服务器的别名.
    9. git remote rm XXX # #删除远程版本库的别名
    10. git push-u remotename master #将本地文件提交到Github的remoname版本库中. The local changes were updated to the GitHub service at this time.


Branch version operation
1. Creating and Merging branches

[Plain]View Plaincopy
    1. Git branch #显示当前分支是master
    2. Git branch new-feature #创建分支
    3. git checkout new-feature #切换到新分支
    4. VI page_cache.inc.php
    5. git add page_cache.inc.php
    6. Git commit-a-M "added initial version of page cache"
    7. Git push Origin new-feature # #把分支提交到远程服务器, simply commits the branching structure and content to the remote, and does not occur with the trunk merging behavior.

2, if the New-feature branch mature, it is necessary to merge into Master

[Plain]View Plaincopy
    1. git checkout Master #切换到新主干
    2. git merge New-feature # #把分支合并到主干
    3. Git branch #显示当前分支是master
    4. git push #此时主干中也合并了new-feature code


git commands use the mind map : "Very material"

Http://www.cnblogs.com/1-2-3/archive/2010/07/18/git-commands.html

Using GIT commands and GitHub projects 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.