• git学习笔记


    本文转载至 http://blog.csdn.net/zhengdanwei/article/details/8563628

     
    本地操作:

    首先当然是初始化,执行了这个命令以后当前目录下就会创建一个本地git版本库
    $ git init

    下面是一个典型的修改-提交过程
    do some development
    $ git add .
    $ git commit

    解释一下上面的代码
    第一行是通常的开发工作,创建、修改、删除文件什么的
    第二行是把当前目录底下所有与上一个版本不同的文件加到commit列表中,如果只想将特定文件进行版本控制的话可以指定add后的参数
    第三行是把上一步添加的文件修改提交到版本库

    $ git log
    $ git blame

    分支管理(最有用的):
    通常情况下你可以维护两个分支master(默认的)和develop(自己起的名字),master用来保存你的稳定版本,develop用来保存你的开发中版本
    一旦你完成了开发中的版本,你就可以将它merge到master分支中
    done some development in develop branch
    $ git commit -a
    $ git checkout master
    $ git merge develop
    最后一行可以替换为git merge --no-ff develop,这样的好处是保持develop和master独立,后来查看master的历史时就不会看到develop修改的日志,而只有在develop分支的历史中才能看到

    在开发过程中可以随时切换分支,就像换个文件夹那么简单,不用担心文件会丢失
    developing in develop branch, need to do some change in master branch
    $ git commit -a
    $ git checkout master
    do some development
    $ git commit -a
    $ git checkout develop
    continue to do some development

    如果切换时你的当前目录底下有会丢失的内容的话,git会给予警告:

    error: Your local changes to the following files would be overwritten by checkout:
    xxxx(会丢失的文件)
    Please, commit your changes or stash them before you can switch branches.
    Aborting

    多人协作开发实践:
    一个主开发者在github上建立一个项目的版本库,然后将其他人添加为协作者

    其他开发者gb,xiaoze...等等配置好Git和GitHub的证书:

    将代码库复制到本地
    $ git clone XXXX.git

    每个开发者创建自己的分支
    $ git checkout -b xiaoze

    然后在自己的分支上开发
    do some development
    $ git commit -a
    $ git push origin xiaoze

    从开发者需要跟随主版本更新的时候:
    $ git fetch origin master 首先从远程的origin的master主分支下载最新的版本到origin/master分支上
    $ git merge origin/master 合并到当前分支上

    查看其他成员更新日志
    $ git log 

    主开发者负责合并从开发者的分支
    $ git fetch origin
    $ git diff xiaoze
    $ git merge xiaoze


    参考:
    http://log.medcl.net/item/2010/03/git-quick-start/
    http://www.ruanyifeng.com/blog/2012/07/git.html
    http://www.open-open.com/lib/view/open1328069733264.html
    http://www.open-open.com/lib/view/open1328069889514.html
  • 相关阅读:
    导出表结构
    smarty cache
    浏览器插件
    互联网技术网站介绍
    目录拷贝
    sphinx搜索不到
    powerdesigner 导出数据库表结构
    PowerDesigner 连接 mysql
    update join
    ClipboardJS的坑,
  • 原文地址:https://www.cnblogs.com/Camier-myNiuer/p/4163929.html
Copyright © 2020-2023  润新知