JSFiddle - React, Tailwind, and code Playground

by Frank Liu

HTML

<div id="content_views" class="markdown_views prism-atom-one-dark">
                    <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
                        <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
                    </svg>
                    <h2><a name="t0"></a><a id="gitcommit_0"></a>git合并多个<a href="https://so.csdn.net/so/search?q=commit&amp;spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" data-report-click="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=commit&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;commit\&quot;}&quot;}" data-tit="commit" data-pretit="commit">commit</a>的方法总结</h2> 
<p>当我们向开源社区提交代码时,一般都会要求简化commit。即多个commit合并为一个commit再提交。</p> 
<p>合并多个commit分两种情况,下面一一讲解。</p> 
<ol><li>要合并的所有commit都还没有push到远程仓库。</li><li>有些commit已经push到了远程仓库。</li></ol> 
<h3><a name="t1"></a><a id="1_commitpush_8"></a>1. 要合并的commit还没有push到远程仓库</h3> 
<p>这种情况下有三种命令可以实现要求:</p> 
<p>第一种(推荐):使用<code>git reset</code>方式(因为比较好理解,也是笔者推荐的方式)。步骤如下:</p> 
<ol><li><code>git log</code>查看要合并的commit.记住最早的commit号。</li><li><code>git reset commit_number</code>.回退到此commit号。因为没有使用<code>--hard</code>,所以内容都保存在工作区。</li><li><code>git add .</code>将回退的的内容再次添加到暂存区</li><li><code>git commit -m "comment"</code>.再次提交。</li><li><code>git log</code>。使用此命令查看,发现合并完成。<br> 这种方式主要利用了<code>git reset</code>回退时并不会删除工作区的内容。因此可以一次性重新提交。</li></ol> 
<p>第二种:使用<code>git commit --amend</code>方式。只能合并当前要提交的和最近一次提交的commit.</p> 
<ol><li>修改工程文件。</li><li><code>git add .</code>将文件添加到暂存区。</li><li><code>git commit --amend -m "commet"</code>.提交。</li><li><code>git log</code>。使用此命令查看,发现与最近一次commit为一个commit。</li></ol> 
<p>第三种:使用<code>git rebase</code>变基的方式。需要理解rebase的原理。自行百度吧。</p> 
<h3><a name="t2"></a><a id="2_commitpush_29"></a>2. 有些commit已经push到了远程仓库</h3>...