Linux git(12)----分支管理策略

17 篇文章 0 订阅
用到的新命令
1.git merge --no-ff 分支名:合并分支,且禁用Fast forward

1.新建分支dev,修改readme.txt,add 和 commit,切换到主分支master
[root@VM_0_11_centos learn_git]# git checkout -b dev
Switched to a new branch 'dev'
[root@VM_0_11_centos learn_git]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
Creating a new branch is quick and simple.
分支管理策略    <== 新加的一行
[root@VM_0_11_centos learn_git]# git add readme.txt
[root@VM_0_11_centos learn_git]# git commit -m "add one line"
[dev 34b89e8] add one line
 1 file changed, 1 insertion(+)
[root@VM_0_11_centos learn_git]# git checkout master 
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 4 commits.
  (use "git push" to publish your local commits)

2.合并dev分支,请注意--no-ff参数,表示禁用Fast forward,本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。
[root@VM_0_11_centos learn_git]# git merge --no-ff -m "merge with no-ff" dev
Merge made by the 'recursive' strategy.
 readme.txt | 1 +
 1 file changed, 1 insertion(+)

3.查看分支历史,不使用Fast forward模式,merge后就如图1
[root@VM_0_11_centos learn_git]# git log --graph --pretty=oneline --abbrev-commit
*   bee4f9e merge with no-ff
|\  
| * 34b89e8 add one line
|/  
*   dc82b39 conflict fixed
|\  
| * 328da23 and simple
* | 66fe1ee & simple
|/  
* 1d24cf9 branch test
* c0ef94e modify text.txt
* 4ab772a add text.txt
* f781044 delete test.txt
* 0142aa9 add test.txt
* 723e215 add reacks changes
* e45a7a3 understand how stage works
* 95a6a5b distributed under the GPL
* c0dafc1 add distributed
* ee6982d create a readme.txt
[root@VM_0_11_centos learn_git]# 

图1

 

说明:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值