git命令快速参考

1 安装和初始化

  

配置全局用户名和电子邮件地址
prompt> git config --global user.name "Your name"
prompt> git config --global user.email "you@example.com" 
为特定版本库配置用户名和电子邮件地址
prompt> cd /path/to/repo
prompt> git config user.name "Your name"
prompt> git config user.email "you@example.com"
在命令行中使用不同颜色显示不同内容
prompt> git config --global color.ui "auto"
初始化新版本库
prompt>  mkdir /path/to/repo
prompt> cd /path/to/repo
prompt> git init
...
...
prompt> git add .
prompt> git commit -m "initial import"
克隆版本库
prompt> git clone <repository url>
在本地版本库中设置远程版本库的别名
prompt> git remote add <remote repository> <repository url> 

2 日常操作

添加新文件或暂存已有文件上的改动,然后提交
prompt> git add <some file>
prompt> git commit -m "<some message>"
暂存已有文件上的部分修改
prompt> git add -p [<some file> [<some file> [and so on]]]
使用交互方式添加文件
prompt> git add -i
清楚工作目录树中的修改
prompt> git checkout HEAD <some file> [<some file>]
取消已暂存但尚未提交的修改的暂存标识
prompt> git reset HEAD <some file> [<some file>]

后续分支、历史、远程版本库

posted @ 2012-04-19 09:44  ziyoudefeng  阅读(320)  评论(0编辑  收藏  举报