git合并分支

Git分支介绍
 
几乎所有的版本控制系统都以某种形式支持分支。 使用分支意味着你可以把你的工作从开发主线上分离开来,以免影响开发主线。
Git 处理分支的方式可谓是难以置信的轻量,创建新分支这一操作几乎能在瞬间完成,并且在不同分支之间的切换操作也是一样便捷。 与许多其它版本控制系统不同,Git 鼓励在工作流程中频繁地使用分支与合并,哪怕一天之内进行许多次。

第一步:查看分支
[root@zxw6 zxw]# git branch
* master

第二步:创建分sa支
[root@zxw6 zxw]# git branch zxw
[root@zxw6 zxw]# git branch
* master
zxw

第三步:切换分支
[root@zxw6 zxw]# git checkout zxw
Switched to branch 'zxw'
[root@zxw6 zxw]# git branch
master
* zxw
[root@


第四步:写入文件到分支
root@zxw6 zxw]# echo "ZXW" >> test
[root@zxw6 zxw]# git add .
[root@zxw6 zxw]# git log
commit d837a868493c2209f0caa303a8339c9caed34ba2
Author: Your Name <you@example.com>
Date: Mon Jul 15 07:56:18 2019 -0400

v4

commit c866a1da7133f5c7fc04ccc6bc862f7e4dee478f
Author: Your Name <you@example.com>
Date: Mon Jul 15 07:18:45 2019 -0400

v1
[root@zxw6 zxw]# cat test
zhaoxiaowei
zhao
ZXW
[root@zxw6 zxw]# git add .
[root@zxw6 zxw]# git commit -m "v6"
[zxw 94bd598] v6
1 file changed, 1 insertion(+)
[root@zxw6 zxw]# git log
commit 94bd598acd9d415ef72ceb4f63222b2fc7268a76
Author: Your Name <you@example.com>
Date: Mon Jul 15 20:57:29 2019 -0400

v6

commit d837a868493c2209f0caa303a8339c9caed34ba2
Author: Your Name <you@example.com>
Date: Mon Jul 15 07:56:18 2019 -0400

v4

commit c866a1da7133f5c7fc04ccc6bc862f7e4dee478f
Author: Your Name <you@example.com>
Date: Mon Jul 15 07:18:45 2019 -0400

v1

第五步:切换到主分支
[root@zxw6 zxw]# git checkout master
Switched to branch 'master'
[root@zxw6 zxw]# git branch
* master
zxw
[root@zxw

第六步:合并到组分支
[root@zxw6 zxw]# git merge zxw
Updating d837a86..94bd598
Fast-forward
test | 1 +
1 file changed, 1 insertion(+)
[root@zxw6 zxw]# cat test
zhaoxiaowei
zhao
ZXW
[root@zxw6 zxw]# git log
commit 94bd598acd9d415ef72ceb4f63222b2fc7268a76
Author: Your Name <you@example.com>
Date: Mon Jul 15 20:57:29 2019 -0400

v6

commit d837a868493c2209f0caa303a8339c9caed34ba2
Author: Your Name <you@example.com>
Date: Mon Jul 15 07:56:18 2019 -0400

v4

commit c866a1da7133f5c7fc04ccc6bc862f7e4dee478f
Author: Your Name <you@example.com>
Date: Mon Jul 15 07:18:45 2019 -0400

v1

 

原文地址:https://www.cnblogs.com/itzhao/p/11301113.html