美文网首页Git
(4.5) git分支管理-feature分支

(4.5) git分支管理-feature分支

作者: Wei_Lai | 来源:发表于2018-11-07 23:33 被阅读0次

添加一个新功能时,不想把主分支搞乱。所以,每添加一个新功能,最好新建一个feature分支,在上面开发,完成后,合并,最后,删除该feature分支。

eg:现在,加一个Vulcan的新功能,该功能计划用于下一代星际飞船。
先添加feature-vulcan分支

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

开发完毕:

$ git add vulcan.py

$  git status
On branch feature-vulcan
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   hello.py
        new file:   vulcan.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   readme.md

切回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分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用大写的-D参数。。

现在我们强行删除:

$ git branch -D feature-vulcan
Deleted branch feature-vulcan (was 287773e).

终于删除成功!

小结

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

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

相关文章

  • (4.5) git分支管理-feature分支

    添加一个新功能时,不想把主分支搞乱。所以,每添加一个新功能,最好新建一个feature分支,在上面开发,完成后,合...

  • Git | 分支管理

    git分支管理 主分支 功能分支 - feature 预发布分支 - release 修补bug分支 - fixbug

  • git工作流

    分支 git工作流使用多个分支来完成版本管理工作。这些分支包括master分支、develop分支、feature...

  • git 基本操作介绍

    remote 远程仓库 master 分支 feature 分支 本地分支 clone 项目:git clone ...

  • Git开发新功能创建分支并合并

    新建一个feature分支 切换新分支 开发ing... 分支提交 git status

  • git相关命令

    命名 git 分支分为集成分支、功能分支和修复分支,分别命名为 develop、feature 和 hotfix ...

  • git常用命令

    分支管理 git 切换分支 git 查看远程分支 git 查看本地分支 git 创建本地分支 git 删除本地分支...

  • 分支管理

    本节内容: 创建与合并分支 解决冲突 分支管理策略 bug分支 Feature分支 多人协作

  • GIT 常用命令

    克隆指定分支:git clone -b feature/interface ssh://git@git.sanku...

  • git

    1.git checkout 分支名(如 feature/mybranch) (切换到指定开发分支)2.g...

网友评论

    本文标题:(4.5) git分支管理-feature分支

    本文链接:https://www.haomeiwen.com/subject/kaabxqtx.html