GIT学习----第十五节:Feature分支

2021-01-30 13:07:58 浏览数 (2)

学习目的

  1. 如何对未进行合并的分支进行强制删除?

强制删除未合并分支

  1. 建立并切换新功能分支feature-001
代码语言:javascript复制
$ git checkout -b feature-001
Switched to a new branch 'feature-001'
M       readme.txt
  1. 查看工作区
代码语言:javascript复制
$ git status
On branch feature-001
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.txt

no changes added to commit (use "git add" and/or "git commit -a")
  1. 提交
代码语言:javascript复制
$ git add readme.txt

$ git commit -m "测试新功能分支"
[feature-001 6edb4e3] 测试新功能分支
 1 file changed, 2 insertions( ), 3 deletions(-)
  1. 切换回master分支
代码语言:javascript复制
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 13 commits.
  (use "git push" to publish your local commits)
  1. 突然该功能不要了,并且需要删除该功能分支
代码语言:javascript复制
$ git branch -d feature-001
error: The branch 'feature-001' is not fully merged.
If you are sure you want to delete it, run 'git branch -D feature-001'.
  1. 有提示可看出
代码语言:javascript复制
$ git branch -D feature-001
Deleted branch feature-001 (was b1f9f41).

总结

  1. 新功能和bug修复一样,都需要进行创建新的分支进行处理;
  2. 当没有合并分支要删除分支的时候采用强制删除分支:git branch -D

0 人点赞