文章摘要:

本文描述了github命令说明及简单的使用方法。


远程仓库管理

查看远程服务器地址和仓库名称

$git remote -v

查看远程服务器仓库状态

$git remote show origin

添加远程仓库地址并指定别名

$ git remote add origin https://github.com/chun912/test.git

格式:git remote add [alias] [url]

设置/修改远程仓库地址

$ git remote set-url origin https://github.com/chun912/test.git 

删除远程仓库(未测试)
git remote rm [repository]


在本地新建一个版本库,并在当前目录中创建一个.git文件夹.

$ git init

获取一个对应的远程版本库, 创建一个本地副本;

$ git clone https://github.com/chun912/test.git

提交修改
将工作文件修改提交到本地暂存区

$ git add README.md

将所有修改过的工作文件提交暂存区;

$ git add .

提交修改:

$ git commit -m "first commit"

注意事项:
-m选项指定提交信息说明(必要);

提交所有修改过的文件(除了新建文件)

$ git commit -a -m "first commit"

-a选项,可以直接跳过add命令;


推送本地数据至远程仓库

git push [alias] [branch]

示例:
将本地主分支推到远程主分支

$ git push origin master

-u表示客户端首次提交

$ git push -u origin master

创建版本库示例:

$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin https://github.com/chun912/test.git
$ git push -u origin master

参考文章:
http://www.cnblogs.com/cspku/articles/Git_cmds.html

http://www.ihref.com/read-16369.html