Linux git(14)----Feature分支

微笑、不失礼 提交于 2020-01-25 20:04:06
用到的新命令
1.git branch -D 分支名:要丢弃一个没有被合并过的分支,可以通过该命令强行删除。

1.新建分支feature
[root@VM_0_11_centos learn_git]# git checkout -b feature
Switched to a new branch 'feature'

2.添加feature.txt文件,add 和 commit
[root@VM_0_11_centos learn_git]# vim feature.txt
[root@VM_0_11_centos learn_git]# git add feature.txt
[root@VM_0_11_centos learn_git]# git status 
# On branch feature
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   feature.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       "q\033"
[root@VM_0_11_centos learn_git]# git commit -m "add feature.txt"
[feature 441816d] add feature.txt
 1 file changed, 1 insertion(+)
 create mode 100644 feature.txt

3.正常情况下feature分支和bug分支是类似的,合并,然后删除,但现在要消除该分支
[root@VM_0_11_centos learn_git]# git branch -d feature 
error: The branch 'feature' is not fully merged.
If you are sure you want to delete it, run 'git branch -D feature'.
<==销毁失败。Git友情提醒,feature分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用大写的-D参数。

4.-D 删除成功
[root@VM_0_11_centos learn_git]# git branch -D feature 
Deleted branch feature (was 441816d).
[root@VM_0_11_centos learn_git]# git branch 
  dev
* master

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!