git安装:
root@ubuntu~# apt-get install git
git配置githup/自己的git服务器端账号, 即在用户的home目录下生成.gitcofig文件,可手动修改:
root@ubuntu~# git config --global user.name "Your Name Here"
root@ubuntu~# git config --global user.email your_email@example.com
root@ubuntu~# git config --global color.ui true
查看已有的配置信息:root@ubuntu~# git config --list
git创建仓库(repository,老外简写repo):
新建项目目录,eg: cd /root/mygit
1、首次将本地的项目初始化到git服务器:
root@ubuntu~# git init #创建一个空的repository,在当前目录下生成了.git文件夹
root@ubuntu~# git add *
root@ubuntu~# git commit -m ‘initial project version‘
root@ubuntu~# git remote add origin git@github.com:username/project_name.git # 即刚刚创建的仓库的地址
root@ubuntu~# git push -u origin master #推送代码到远程代码库
2、将git服务器代码初始化到本地:
root@ubuntu~#git status #查看状态
root@ubuntu~#git commit -m "log here" #不加参数-m,则默认使用vi打开一个文件写入log #等同于svn的commit
root@ubuntu~#git status
1 _______________________________ 2 | | 3 | histroy | 4 |_______________________________| 5 | 6 | 7 | git commit 8 _______________|_______________ 9 | | 10 | staging area | 11 |_______________________________| 12 | 13 | 14 | git add 15 ________________|_______________ 16 | | 17 | working dir | 18 |_______________________________|
root@ubuntu~#git status -s #查看三者之间的是否相同,标记位:M , MM,
root@ubuntu~#git diff #比较working dir 与staging area之间的差异
root@ubuntu~#git diff --staged #比较staging area 与 history之间的差异,用于add之后检测
、
原文:http://www.cnblogs.com/chris-cp/p/5042033.html