秒懂Git分支的合并机制

本文介绍了Git的基本分支和合并机制,包括快进和合并提交两种情况。快进模式下,合并只是将分支指针向前移动。而合并提交时,Git创建一个新的合并快照,并生成一个拥有多个父提交的特殊合并提交。当遇到冲突时,需解决冲突后再进行stage和commit。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Basic Branching and Merging

两种合并的情况:Fast-forward,merge-commit

1. Fast-forward 快进

when you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a “fast-forward.”

如下:将hotfix分支合并到master分支上,只是将master分支上的指针向前移了一下。

$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
 index.html | 2 ++
 1 file changed, 2 insertions(+)

在这里插入图片描述

2. merge commit 合并提交

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值