学习目的
- 如何对未进行合并的分支进行强制删除?
强制删除未合并分支
建立并切换新功能分支feature-001
1
2
3$ git checkout -b feature-001
Switched to a new branch 'feature-001'
M readme.txt查看工作区
1
2
3
4
5
6
7
8
9$ 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
2
3
4
5$ git add readme.txt
$ git commit -m "测试新功能分支"
[feature-001 6edb4e3] 测试新功能分支
1 file changed, 2 insertions(+), 3 deletions(-)切换回master分支
1
2
3
4$ 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
2
3$ 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
2$ git branch -D feature-001
Deleted branch feature-001 (was b1f9f41).
总结
- 新功能和bug修复一样,都需要进行创建新的分支进行处理;
- 当没有合并分支要删除分支的时候采用强制删除分支:git branch -D
其他
QQ交流群: 264303060