<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gerry Tan</title>
    <description>The latest articles on DEV Community by Gerry Tan (@gerrytan).</description>
    <link>https://dev.to/gerrytan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F571911%2F8c29ac79-8cf6-4d78-970d-e3264f682d0e.png</url>
      <title>DEV Community: Gerry Tan</title>
      <link>https://dev.to/gerrytan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gerrytan"/>
    <language>en</language>
    <item>
      <title>Fast clone of large git repo to read code in IDE</title>
      <dc:creator>Gerry Tan</dc:creator>
      <pubDate>Wed, 27 Aug 2025 07:33:16 +0000</pubDate>
      <link>https://dev.to/gerrytan/fast-clone-of-large-git-repo-to-read-code-in-ide-4la2</link>
      <guid>https://dev.to/gerrytan/fast-clone-of-large-git-repo-to-read-code-in-ide-4la2</guid>
      <description>&lt;p&gt;How often do you find yourself wanting to clone a repo owned by someone else just to load it in your IDE for quick searching / improved navigation / syntax highlighting / etc.?&lt;/p&gt;

&lt;p&gt;This is problematic on a large repo with tons of history because the initial full clone can take an hour or more!&lt;/p&gt;

&lt;p&gt;Fear not! Shallow git clone to the rescue. Next time you're in this situation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;git clone --depth=1 &amp;lt;url_of_the_repo&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Load the code in the IDE&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You'll notice the clone will be a lot faster!&lt;/p&gt;

&lt;p&gt;A shallow clone works fine if all you do is just reading code in IDE. However &lt;a href="https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone/" rel="noopener noreferrer"&gt;other functionalities are limited / won't work&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;What you should do right after a shallow clone is open a new terminal window, and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch --unshallow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which will fetch all those long history. &lt;/p&gt;

&lt;p&gt;Let this run for however long it wants (and make sure you're not on limited mobile data plan 😉).&lt;/p&gt;

&lt;p&gt;The bottom line is, using this method you can temporarily bypass the expensive fetching of full history, and get only the latest version for immediate reading 🍻.&lt;/p&gt;

&lt;p&gt;And by the way most CI/CD pipeline does a shallow clone too since all they care is the last version of the code.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Squash git commits before pushing</title>
      <dc:creator>Gerry Tan</dc:creator>
      <pubDate>Wed, 09 Jul 2025 08:33:28 +0000</pubDate>
      <link>https://dev.to/gerrytan/squash-git-commits-before-pushing-2am8</link>
      <guid>https://dev.to/gerrytan/squash-git-commits-before-pushing-2am8</guid>
      <description>&lt;p&gt;Given the following commits on a &lt;code&gt;feature/something-cool&lt;/code&gt; branch:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdj784o939zbshjols4if.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdj784o939zbshjols4if.png" alt="git commits before squashing" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The git command &lt;code&gt;git rebase -i A&lt;/code&gt; will let you squash &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;D&lt;/code&gt; into a new commit &lt;code&gt;E&lt;/code&gt; like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju8agesuy2x9vqabepar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju8agesuy2x9vqabepar.png" alt="git commits after squashing" width="800" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(Observe how the commit hash &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;D&lt;/code&gt; are gone, replaced with &lt;code&gt;E&lt;/code&gt;., This will be important for the next section)&lt;/p&gt;

&lt;p&gt;This is especially useful to tidy up local commits with crude messages like &lt;code&gt;fixed typo&lt;/code&gt;, &lt;code&gt;whitespaces&lt;/code&gt; or &lt;code&gt;unit test failures&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Remember that your colleagues (or anyone on the internet if your project is open source) often refer to git history to get more context of particular implementation.&lt;/p&gt;

&lt;p&gt;Popular IDE comes with some sort of &lt;a href="https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-blame" rel="noopener noreferrer"&gt;git blame&lt;/a&gt; feature so reader can understand when / where / why a particular implementation is done a certain way.&lt;/p&gt;

&lt;p&gt;Alternatively, you can &lt;strong&gt;set your repo to do squash-on-merge strategy&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  But don't overdo it during active code review
&lt;/h1&gt;

&lt;p&gt;Say your colleague leaves bunch of code review comments on your PR at commit &lt;code&gt;E&lt;/code&gt;, and you push more changes to address them, they would want to know "what's changed since &lt;code&gt;E&lt;/code&gt;", so avoid doing any rebase that rewrites &lt;code&gt;E&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Bad example: &lt;code&gt;E&lt;/code&gt; is replaced by &lt;code&gt;F&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fas8fgt0so6jwnlv4w78v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fas8fgt0so6jwnlv4w78v.png" alt="Bad example: commit E is rewritten into F" width="800" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
