• Feature分支


    软件开发中,总有无穷无尽的新的功能要不断添加进来。

    添加一个新功能时,你肯定不希望因为一些实验性质的代码,把主分支搞乱了,所以,每添加一个新功能,最好新建一个feature分支,在上面开发,完成后,合并,最后,删除该feature分支。

    现在,你终于接到了一个新任务:开发代号为Vulcan的新功能,该功能计划用于下一代星际飞船。

    于是准备开发:

    $ git checkout -b feature-vulcan
    Switched to a new branch 'feature-vulcan'
    

    5分钟后,开发完毕:

    $ git add vulcan.py
    $ git status
    # On branch feature-vulcan
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   vulcan.py
    #
    $ git commit -m "add feature vulcan"
    [feature-vulcan 756d4af] add feature vulcan
     1 file changed, 2 insertions(+)
     create mode 100644 vulcan.py
    

    切回dev,准备合并:

    $ git checkout dev
    

    一切顺利的话,feature分支和bug分支是类似的,合并,然后删除。

    但是,

    就在此时,接到上级命令,因经费不足,新功能必须取消!

    虽然白干了,但是这个分支还是必须就地销毁:

    $ git branch -d feature-vulcan
    error: The branch 'feature-vulcan' is not fully merged.
    If you are sure you want to delete it, run 'git branch -D feature-vulcan'.
    

    销毁失败。Git友情提醒,feature-vulcan分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用命令git branch -D feature-vulcan

    现在我们强行删除:

    $ git branch -D feature-vulcan
    Deleted branch feature-vulcan (was 756d4af).
    

    终于删除成功!

    开发一个新feature,最好新建一个分支;

    如果要丢弃一个没有被合并过的分支,可以通过git branch -D <name>强行删除。

  • 相关阅读:
    C#调用C++ memcpy实现各种参数类型的内存拷贝 VS marshal.copy的实现 效率对比
    UGUI 事件穿透规则
    UGUI 锚点设置为四方扩充模式然后设置局部坐标为0将出现什么问题
    UNITY polygon collider不随物体旋转
    android Handler机制 消息机制
    java final finally finalize
    collection 和 collections
    java 不通过第三个字符串,实现一个字符串倒序
    ArrayList,Vector,LinkedList
    String StringBuffer stringbuilder 区别
  • 原文地址:https://www.cnblogs.com/jeremylee/p/5537837.html
Copyright © 2020-2023  润新知