1. 安装

  1. sudo apt-get install git-core
2.  初始化git仓库(一个已有的项目)如hello

  1. cd hello
  2. git init
  3. git add *
  4. git commit -a -m "hello project"

3. git本地clone仓库

  1. git clone /path/to/hello
4. git 远程clone(使用ssh)

  1. git clone user@server:/path/to/hello
5.  修改数据并提交

  1. vi hello.c #modify the file
  2. git commit -m "add comment" #本地提交
  3. git push orgin master #提交到服务器
  4. git pull origin master #从服务器同步代码到本地
6. git 常用命令

  1. git rm #删除文件
  2. git checkout master #检出master代码
  3. git checkout -b testing master #新建分支
  4. git merge #合并分支
  5. git help #查看git 常用命令
7. git failed to push 问题
参考:http://blog.sunzy.org/?p=341

解决办法:
一,在服务器上初始化仓库的时候用git –bare init;

二,如果用的是git init的话,就要修改下服务器上的配置(.git/config),添加:
[receive]
denyCurrentBranch = ignor
09-03 22:25