Git初次使用笔记

比较好的git学习笔记博客:
 
一,Git在windows环境下安装
    在 http://msysgit.github.io/  下载Git安装包,
,然后就像普通安装包那样直接安装就ok
      (Ps,因为公司使用了ggh这个扩展工具,所以我在以上装完git工具后,把ggh拷贝到我的git安装目录,第一次初始化ggh,使用 ggh steup)
二、安装好后,进行一些Git的初始化配置
        git config --global user,name Jerry Qiu
        git config --global user.email XXX-XXX@qq.com
        git config --global color.ui true
        git config --global core.editor vim
三、使用Git从clone某个项目
       git gerrit-clone ssh://XXXX-XXX/project_name  [local folder name]
四、简单常用命令
       git pull              获得最新代码
       git  log              查看代码历史修改
       git  log --stat
       git checkout file_name   放弃该文件在本地的修改,更新到主干一样的内容
       git branch         查看分支状态
       git checkout branch_name   切换分支
       git start feature1 master      在本地创建一个feature1分支
       git  status   查看代码修改状态
        git diff 查看文件被修改的内容
 五、提交代码修改
        首先 git  status   查看你修改那部分代码
        然后 git add file 或者 git rm file   添加或者删除你修改的文件
                git commit -m “log infomation” 注意:commit操作只记录到本地数据中
                                                                       建议commit log信息为:第一行为 brief。空一行,然后是detail
                  例子:  git commit -m " modify test 1      (简要描述)
                                                          (空行)
                                                            when xxx,it xxx,。。。。。(详细描述,可多行)"
            修改完成上传服务器前,先同步代码到最新状态 git pull
             然后   git upload  
  六、对同一个目的的修改,可以使用多个 patch set
          你对刚才提交的代码有更好的建议,那么本地修改后,继续 git add file,
           然后                                                                                git commit --amend
            最后在                                                                           git pull 
                                                                                                 git upload
 七、git log --oneline  每次commit只显示一行,简洁清晰的显示commit记录
  八、git reset --hard HEAD~ 回滚到当前分支的前一次commit
       git branch branch_name origin/marst 已marst的branch基础上开一个本地分支。

posted on 2015-02-06 10:26  背包客的前奏  阅读(185)  评论(0)    收藏  举报

导航