添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
冷静的树叶
·
VueJS:使用v-for从嵌套对象列表递归 ...
·
2 月前
·
面冷心慈的熊猫
·
发送推送通知 [IM 开发文档]
·
5 月前
·
豁达的丝瓜
·
绿联 ...
·
7 月前
·
开朗的枇杷
·
霍总,夫人的十个哥哥又来催离婚了(红十三)_ ...
·
11 月前
·
大方的蚂蚁
·
时代倾城六期(时代汀蓝),长沙时代倾城六期( ...
·
1 年前
·
link管理
›
Git tip: squash intermediate commits - Liquid Light
https://www.liquidlight.co.uk/blog/git-tip-squash-intermediate-commits/
暴走的单车
11 月前
</noscript> <div class="page" id="top"> <div class="header"><div class="wrapper"><div class="logo"><div class="wrapper"><a href="https://www.liquidlight.co.uk/" title="Liquid Light - Award winning web design agency"><img src="/assets/new/img/logo_print.png" width="200" height="53" alt="Liquid Light" title="Liquid Light"/></a></div></div><nav class="mobileNavigation"><ul><li class="menu" data-target=".navigationWrapper"><span>Menu</span></li></ul></nav><div class="navigationWrapper"><div id="search"><form action="/search/" method="get" itemprop="potentialAction" itemscope="" itemtype="https://schema.org/SearchAction"><fieldset><legend>Site search</legend><label><span>Search keyword(s): </span><input name="query" placeholder="" itemprop="query-input" type="text" size="20" autocomplete="off" aria-label="Search keyword(s)"/></label><button class="search" title="Search"><span>Search</span></button></fieldset></form></div><nav class="primaryNavigation"><div class="wrapper"><ul class="navigation horizontal" role="list"><li class="pageHome hasWideTop"><a href="/" title="Empowering you to solve the world’s biggest challenges" accesskey="h"><span>Home</span></a></li><li class="hasChildren hasWideTop"><a href="/services/" title="The right mix for the most complex of challenges" accesskey="s"><span>Services</span></a><ul class="subNav"><li class="hasWideTop"><a href="/services/strategy-insights-definition/" title="Strategy, Insights & Definition"><span>Strategy, Insights & Definition</span></a></li><li class="hasWideTop"><a href="/services/product-design-development/" title="Product Design & Development"><span>Product Design & Development</span></a></li><li class="hasWideTop"><a href="/services/brand-identity-development/" title="Brand Identity & Development"><span>Brand Identity & Development</span></a></li><li class="hasWideTop"><a href="/services/ongoing-support-optimisation/" title="Ongoing Support & Optimisation"><span>Ongoing Support & Optimisation</span></a></li></ul></li><li class="hasWideTop"><a href="/case-studies/" title="Case Studies" accesskey="t"><span>Case Studies</span></a></li><li class="hasChildren hasWideTop videoPage"><a href="/about/" title="Empowering our clients to solve the world’s biggest challenges" accesskey="a"><span>About</span></a><ul class="subNav"><li class="hasWideTop"><a href="/about/careers/" title="Careers"><span>Careers</span></a></li></ul></li><li class="active hasWideTop"><a href="/blog/" title="Blog" accesskey="b" class="active"><span>Blog</span></a></li><li class="hasWideTop"><a href="/contact/" title="Contact" accesskey="c"><span>Contact</span></a></li></ul></div></nav></div></div></div> <main id="content"> <div class="container"> <!--TYPO3SEARCH_begin--> <div class="pageLayout oneColumnPage"> <div class="wrapper"> <div class="pageRow contentHeader header"> <div class="wrapper"> <div class="bannerWrap"> <div class="banner" style="background-image: url('/fileadmin/uploads/ll/Banners/emily-working.jpg');"/> </div> <div class="headerContent"> <div class="breadcrumb"> <div class="wrapper"> <ol itemprop="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList"> <li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem"> <meta itemprop="position" content="1"/> <a href="/" itemprop="item"> <span itemprop="name"> Home </span> </a> </li> </ol> </div> </div> <h1 itemprop="name"><span>Git tip: squash intermediate commits</span></h1> </div> </div> </div> <div class="pageRow content" itemprop="mainContentOfPage" itemscope="" itemtype="http://schema.org/WebPageElement"> <div class="wrapper"> <div class="pageColumn primary"> <div class="wrapper"> <a id="c2284"/> <div class="container"> <div class="news single "> <div class="header"> <div class="meta"> <p>Written by <span class="author"><a href="/blog/author/joao-augusto/">João Augusto</a></span> <span class="date"> on 16<sup>th</sup> October 2020</span> </p> <p><span class="date">(Last updated 5<sup>th</sup> July 2023)</span></p> </div> </div> <div class="content"> <div class="wrapper"> <div class="contentWrapper"><p>Often we write a lot of intermediate commit messages on a task where only one or two commits would be sufficient. Take the following example:</p> <pre class="language-bash"><code>5596df4 FE: Fix layout for mobile --- newer commit --- 5596df4 FE: More style adjustments 13c4c41 FE: Adjust margins 3f4b0ce Bug: Fix typo **a63d5af** Task: Create feature X --- initial commit --- b32af23 FE: Create banner 17daeff Bug: Fix this ...</code></pre> <p>Note that all commits since <code>a63d5af</code> (the initial commit) are small changes that relate directly with <em>Create feature X</em> task*.* These are the intermediate commits, and in the example above we want to combine them into single commit. So, today we are going to cover the basics of squashing intermediate commits into single one using the <code>git rebase --interactive</code> command.</p> <h2>Merge commits</h2> <p>To merge the commits you can either pass the number of commits you want to merge or use hash of the commit you want to rewrite from.</p> <p>Use <code>git rebase --interactive HEAD~N</code> to merge a number of commits, where <code>N</code> is the number of commits starting from the most recent, so for example to merge the 5 newest commits you do:</p> <pre class="language-bash"><code>$ git rebase --interactive HEAD~5</code></pre> <p>Or, use <code>git rebase --interactive [commit-hash]</code> to merge all commits above the given commit hash. Note the <code>commit-hash</code> is the hash of the commit just before the first one you want to rewrite from, in our example is <code>b32af23</code>.</p> <pre class="language-bash"><code>5596df4 FE: Fix layout for mobile --- newer commit --- 5596df4 FE: More style adjustments 13c4c41 FE: Adjust margins 3f4b0ce Bug: Fix typo **a63d5af** Task: Create feature X --- initial commit --- b32af23 FE: Create banner --- ⬆️ merge all commits above this ⬆️ --- ...</code></pre> <p>Like this:</p> <pre class="language-bash"><code>$ git rebase --interactive b32af23</code></pre> <h2>The squash</h2> <p>Next, your editor should pop up, showing a few options to squash the commits. Note the commits are in reverse order the top being one the initial commit.</p> <p>You mark a commit as <em>squashable</em> by changing the word <code>pick</code> into <code>squash</code>, as follows:</p> <pre class="language-bash"><code>pick a63d5af Task: Create feature X --- initial commit --- squash 3f4b0ce Bug: Fix typo squash 13c4c41 FE: Adjust margins squash 5596df4 FE: More style adjustments squash 5596df4 FE: Fix layout for mobile --- newer commit ---</code></pre> <p>Save the file and close the editor.</p> <p>Git will squash those commits after one last commit. The editor should pop up one last time for the squash commit. This will be filled with all the commits messages you have squashed, this might be useful for future reference, but they can be removed.</p> <pre class="language-bash"><code>Task: The new Feature X --- the new squash commit ---
推荐文章
冷静的树叶
·
VueJS:使用v-for从嵌套对象列表递归生成_javascript从嵌套的对象列表生成列表值_使用递归从嵌套列表中获取绝对值 - 腾讯云开发者社区 - 腾讯云
2 月前
面冷心慈的熊猫
·
发送推送通知 [IM 开发文档]
5 月前
豁达的丝瓜
·
绿联 安装MariaDB数据库用于Seatable服务 - 智识家园|智识家
7 月前
开朗的枇杷
·
霍总,夫人的十个哥哥又来催离婚了(红十三)_第592章 大结局(二)章节免费阅读无弹窗_书库网
11 月前
大方的蚂蚁
·
时代倾城六期(时代汀蓝),长沙时代倾城六期(时代汀蓝)房价,楼盘户型,周边配套,交通地图,金星北路208号 - 安居客
1 年前