Ubuntu14.04(LTS)gitHub客户端安装
使用GitHub步骤:
1、申请GitHub帐户xxx(申请网址:https://github.com)
2、安装Git客户端(Linux)
$sudo apt-get install git
3、生成密钥对,这样项目可以push到GitHub上
$ssh-keygen -t rsa -C "xxxx@gmail.com"
4、将.ssh/id_rsa.pub拷贝到GitHub网站
~$ssh-keygen -t rsa -C "xxxx@gmail.com"Generatingpublic/private rsa key pair.
Generatingpublic/private rsa key pair.
Enterfile in which to save the key (/home/tianxingjian/.ssh/id_rsa):
Enterpassphrase (empty for no passphrase):
Entersame passphrase again:
Youridentification has been saved in git_rsa.
Yourpublic key has been saved in git_rsa.pub.
Thekey fingerprint is:
…....
5、为了方便,设置ssh不输入口令
$ eval `ssh-agent`
$ ssh-add
(输入passphrase)
6、测试是否能联通GitHub
$ssh git@github.com
如果配置正确,显示
ERROR:Hi xxx! You've successfully authenticated, but GitHub does notprovide shell access
Connectionto github.com closed.
7、设置Git全局用户配置
$ git config --global user.name "xxx"
$ git config --global user.email xxx@gmail.com
8、创建本地新项目工作树
#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
9.更新文件
#vi README
自动commit更改文件
#git commit -a
更新至远程
#git push origin master
10.创建和合并分支
#gitbranch 显示当前分支是master
#gitbranch 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的代码
11.Eclipse中操作git(最新eclipse自带git插件,如果直接用eclipse操作git项目,第8,9,10步骤都可以省略)
(见:http://blog.youkuaiyun.com/luckarecs/article/details/7427605)