<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>git &#8211; 有意与无意之间</title>
	<atom:link href="https://zhangxihai.cn/archives/tag/git/feed" rel="self" type="application/rss+xml" />
	<link>https://zhangxihai.cn</link>
	<description>千淘万漉虽辛苦 吹尽狂沙始到金 - 生命不息 编程不止</description>
	<lastBuildDate>Fri, 25 Jun 2021 03:47:37 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.11</generator>
	<item>
		<title>Git merge fast-forward/&#8211;no&#8211;off/&#8211;squah的区别</title>
		<link>https://zhangxihai.cn/archives/165</link>
					<comments>https://zhangxihai.cn/archives/165#respond</comments>
		
		<dc:creator><![CDATA[胖爷]]></dc:creator>
		<pubDate>Thu, 23 Jan 2014 03:46:37 +0000</pubDate>
				<category><![CDATA[编码]]></category>
		<category><![CDATA[git]]></category>
		<guid isPermaLink="false">https://zhangxihai.cn/?p=165</guid>

					<description><![CDATA[fast-forward 未添加任何参数使用git merge合并分支时即为fast-forward模式，这种模式不是在被合并分支上显示被合并的分支，只保留单条分支记录。在合并时间，GIT直接将HEAD指针指向合并分支的头，完成合并，这是一种”快进&#34;方式的合并。 在这种情况下，删除分支，则分支丢失，只在被合并分支上看到commit提交信息，但并不知...]]></description>
										<content:encoded><![CDATA[<h3>fast-forward</h3>
<p>未添加任何参数使用git merge合并分支时即为fast-forward模式，这种模式不是在被合并分支上显示被合并的分支，只保留单条分支记录。在合并时间，GIT直接将HEAD指针指向合并分支的头，完成合并，这是一种”快进&quot;方式的合并。 在这种情况下，删除分支，则分支丢失，只在被合并分支上看到commit提交信息，但并不知道来源。</p>
<p>合并前</p>
<pre><code>featue       D-&gt;E
            /
master A-&gt;B-&gt;C</code></pre>
<p>合并后</p>
<pre><code>master A-&gt;B-&gt;C-&gt;D-&gt;E</code></pre>
<h3>--no-off</h3>
<p>由于fast-forward方式是一种快进合并，无法体现合并来源，所以--no-off方式就更为有用，--no-off在合并后会保留分支信息，即使被合并的分支删除，也不会丢失。</p>
<p>合并前</p>
<pre><code>featue       D-&gt;E
            /
master A-&gt;B-&gt;C</code></pre>
<p>合并后</p>
<pre><code>featue       D-&gt;E
            /   \
master A-&gt;B-&gt;C---&gt;F</code></pre>
<h3>--squash</h3>
<p>--squash可以将被合并分支上的多余的commit进行合并，它不会移动head，他会忽略之前所有的commit后进行所有，由于之前commit全部被忽略，所以你还需要最后一次commit做一个总结</p>
<pre><code>featue       D-&gt;E
            /  
master A-&gt;B-&gt;C---&gt;F</code></pre>
<pre><code>featue        F
            /  \
master A-&gt;B-&gt;C--&gt;G</code></pre>
<h3>三种模式的适用场景</h3>
<p>fast-forward更适用于多用于协作开发feature或hotfix，由上级领导合并各自开发的feature和hotfix内容，因为这些作为一个整体存在即可，且在开发过程中看见状态</p>
<p>--no-off适合将devlop分支合并到relase分支， 发布分支最终需要合并到master分支上，所以需要保留开发历史，并不适合hotfix向其他分支合并</p>
<p>--squash 适合hotfix向其他分支合并，因为热修复通常都只修复一个单一的整体的BUG。但并不一定适合feature向其他分支合并，因为如果同一个feature， 如果有隔离的 协作的功能，且在同一个迭代周期内完成的， 就需要保留这些信息和状态。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zhangxihai.cn/archives/165/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
