用到的新命令
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
说明: