使用GitHub和Git进行版本控制

参考:http://hi.baidu.com/hk2305621/item/340c150f5820c612addc70f9

http://blog.csdn.net/cdkd123/article/details/8959484

http://www.kuqin.com/managetool/20111119/315043.html

http://www.kuqin.com/managetool/20111113/314830.html

环境:win7

1、Git的优势

为什么不选CVS或SVN

    • Git提交/克隆/pull/push的速度更快
    • Git的绝大多数操作都可以在本地完成,不需要频繁连接服务器。教育网的痛苦你们不懂哇。
    • 分布式,Linus,开源,每个关键词都能High到我…

      2、注册GitHub账号

      GitHub的网址https://github.com/

      3、Git的安装与测试

      请参考http://www.kuqin.com/managetool/20111113/314830.html

      4、Git上传本地代码

      (1)创建远程代码库

      在GitHub上新建一个repository

      (2)创建本地代码库

                 (a)在需要上传的代码文件夹下,右键弹出菜单单击 Git Init Here

                 (b)在Git Bash窗口下输入命令:git status 查看,发现目前还没有增加要上传的文件

      (3)增加要提交的文件

                    (a)右键需要上传的文件夹,右键弹出菜单选择Git Bash

                   (b)右键需要上传的文件夹,右键弹出菜单选择Git Add All Files Now

                     (c)在Git Bash窗口下输入命令:git status 可以查看增加的文件

                   (d)忽略不需要的文件

                            (d1)git rm --cache <file name>  (git rm --cache testBl/Debug/* -r ,表示忽略testBl/Debug下的所有文件 -r表示递归忽略的意思)

                            (d2)http://blog.csdn.net/benkaoya/article/details/7932370(用这个方法我没有成功)

      (4)开始上传本地代码库

                (a)接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都
                 会记录他们。

      [cpp]view plaincopy使用GitHub和Git进行版本控制使用GitHub和Git进行版本控制
      1. $ git config --global user.name "your name"    
      2. $ git config --global user.email "your_email@youremail.com"    


                  (b)添加远程地址

      [cpp]view plaincopy使用GitHub和Git进行版本控制使用GitHub和Git进行版本控制
      1. $ git remote add origin git@github.com:yourName/yourRepo.git    


      这个是你在GitHub网站上新建repository时的那个地址,origin代表本地代码库的意思

               (c)提交更改

                         git commit -m "first commit" 

                (d)上传文件:在Git Bash下输入git push origin master 

      5、成功后你就可以在GitHub网站看到自己的代码文件了

      6、和VS2010的结合

      请参看http://blog.csdn.net/softwave/article/details/7957938

        • 使用GitHub和Git进行版本控制