【转】GitHub使用

1、设置Git全局用户配置

git config --global user.name "xxx"
git config --global user.email xxx@gmail.com

2、创建本地新项目工作树

mkdir new-project
cd new-project
git init
touch README
git add README
git commit -m 'first commit'
#定义远程服务器别名origin
git remote add origin git@github.com:xxx/new-project.git   
#本地和远程合并,本地默认分支为master
git push origin master  

#GitHub网站上就可以看见了, http://github.com/xxx/new-project

3. 更新文件

vi README
#自动commit更改文件
git commit -a     
#更新至远程
git push origin master

4. 创建和合并分支

git branch                                    #显示当前分支是master
git branch new-feature               # 创建分支
git checkout new-feature           #切换到新分支
vi page_cache.inc.php
git add page_cache.inc.php
#Commit 到本地GIT
git commit -a -m "added initial version of page cache"
#合并到远程服务器
git push origin new-feature

#如果new-feature分支成熟了,觉得有必要合并进master
git checkout master
git merge new-feature
git branch
git push 
#则master中也合并了new-feature 的代码
#再登录到GitHub可以看见"Switch Branches"下的分支选项:

转载了 http://blog.csdn.net/richardysteven/article/details/5956854内容。

原文地址:https://www.cnblogs.com/CoderTian/p/4200597.html