<?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>Forem: Pedro Arenas</title>
    <description>The latest articles on Forem by Pedro Arenas (@antonioaren).</description>
    <link>https://forem.com/antonioaren</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%2F1020665%2F446f827e-5278-4975-a424-9430a01b057f.jpg</url>
      <title>Forem: Pedro Arenas</title>
      <link>https://forem.com/antonioaren</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/antonioaren"/>
    <language>en</language>
    <item>
      <title>Git worktree — Stop Stashing, Start Working in Parallel</title>
      <dc:creator>Pedro Arenas</dc:creator>
      <pubDate>Sun, 11 Jan 2026 12:35:06 +0000</pubDate>
      <link>https://forem.com/antonioaren/git-worktree-stop-stashing-start-working-in-parallel-3p17</link>
      <guid>https://forem.com/antonioaren/git-worktree-stop-stashing-start-working-in-parallel-3p17</guid>
      <description>&lt;h2&gt;
  
  
  Introduction: the pain of branch switching 😤
&lt;/h2&gt;

&lt;p&gt;If you’ve worked with Git long enough, you’ve lived this moment:&lt;/p&gt;

&lt;p&gt;You’re deep into a feature. Files are half-written. Tests are failing (on purpose).&lt;br&gt;
Then suddenly:&lt;/p&gt;

&lt;p&gt;“Hey, can you quickly fix this hotfix on main?”&lt;br&gt;
“Can you review this PR locally?”&lt;/p&gt;

&lt;p&gt;So you do the dance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status
git stash
git checkout main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later…&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature/my-work
git stash pop
&lt;span class="c"&gt;# 💥 conflicts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Context lost. Flow broken. Confidence shaken.&lt;/p&gt;

&lt;p&gt;Git has had a solution for this for years — and many developers still don’t use it.&lt;/p&gt;

&lt;p&gt;That solution is git worktree.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is git worktree? 🌳
&lt;/h2&gt;

&lt;p&gt;git worktree lets you check out multiple branches of the same repository at the same time, each in its own directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key idea:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One Git repository&lt;/li&gt;
&lt;li&gt;Multiple working directories&lt;/li&gt;
&lt;li&gt;Each directory has its own checked-out branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You’re not cloning the repo again.&lt;br&gt;
You’re not copying history.&lt;/p&gt;

&lt;p&gt;You’re just creating another view of the same repository.&lt;/p&gt;

&lt;p&gt;Think of it as:&lt;br&gt;
“Parallel checkouts without the pain.”&lt;/p&gt;


&lt;h2&gt;
  
  
  How git worktree works (conceptually) 🧠
&lt;/h2&gt;

&lt;p&gt;A normal Git repo looks like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One &lt;code&gt;.git&lt;/code&gt; directory (history, objects, refs)&lt;/li&gt;
&lt;li&gt;One working directory (your files)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With worktrees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Still one &lt;code&gt;.git&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Multiple working directories&lt;/li&gt;
&lt;li&gt;Each directory:

&lt;ul&gt;
&lt;li&gt;Is on a different branch&lt;/li&gt;
&lt;li&gt;Has its own files&lt;/li&gt;
&lt;li&gt;Is completely isolated from the others&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What's shared:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git history&lt;/li&gt;
&lt;li&gt;Commits&lt;/li&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What's isolated:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Checked-out branch&lt;/li&gt;
&lt;li&gt;Working files&lt;/li&gt;
&lt;li&gt;Uncommitted changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mental model:&lt;/p&gt;

&lt;p&gt;“Multiple terminals, multiple folders, same repo.”&lt;/p&gt;


&lt;h2&gt;
  
  
  git worktree vs traditional branch switching ⚖️
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Traditional workflow:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One working directory&lt;/li&gt;
&lt;li&gt;One branch at a time&lt;/li&gt;
&lt;li&gt;Frequent stashing&lt;/li&gt;
&lt;li&gt;Easy to lose context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;With git worktree:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No stashing&lt;/li&gt;
&lt;li&gt;No dirty working tree problems&lt;/li&gt;
&lt;li&gt;No accidental changes on the wrong branch&lt;/li&gt;
&lt;li&gt;True parallel work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In short:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Branch switching → sequential work&lt;/li&gt;
&lt;li&gt;Worktrees → parallel work&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Practical use cases (real workflows) 🚀
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Feature development + hotfix 🚑
&lt;/h3&gt;

&lt;p&gt;You're working on:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;feature/auth&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Production bug appears on main.&lt;/p&gt;

&lt;p&gt;Instead of stashing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../repo-hotfix main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;repo/           → feature/auth
repo-hotfix/    → main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fix the bug, commit, push — without touching your feature work.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reviewing a PR locally 🔍
&lt;/h3&gt;

&lt;p&gt;You want to check a teammate's branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../repo-pr-123 &lt;span class="nb"&gt;pr&lt;/span&gt;/some-feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open it in your editor. Run tests. Explore freely.&lt;/p&gt;

&lt;p&gt;Your main work stays intact.&lt;/p&gt;




&lt;h3&gt;
  
  
  Experiments and spikes 🧪
&lt;/h3&gt;

&lt;p&gt;Trying a risky refactor?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../repo-experiment experiment/refactor-auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it works → keep it.&lt;br&gt;
If it doesn’t → delete the worktree.&lt;/p&gt;

&lt;p&gt;Zero fear. Zero mess.&lt;/p&gt;


&lt;h3&gt;
  
  
  Release or QA validation 🧪
&lt;/h3&gt;

&lt;p&gt;Keep a stable branch checked out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../repo-release release/1.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run builds, verify fixes, validate QA&lt;br&gt;
while continuing normal feature work elsewhere.&lt;/p&gt;


&lt;h2&gt;
  
  
  Step-by-step: using git worktree 🛠️
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Create a new worktree
&lt;/h3&gt;

&lt;p&gt;From your main repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../my-repo-hotfix main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a new directory&lt;/li&gt;
&lt;li&gt;Checks out main there&lt;/li&gt;
&lt;li&gt;Links it to the same Git repo&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Create a worktree with a new branch
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; feature/payments ../my-repo-payments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Perfect for starting new work.&lt;/p&gt;




&lt;h3&gt;
  
  
  List all worktrees
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/path/repo              abc123  feature/auth
/path/repo-hotfix       def456  main
/path/repo-experiment   ghi789  experiment/refactor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Work normally
&lt;/h3&gt;

&lt;p&gt;Inside a worktree:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git commit&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git push&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything behaves exactly like a normal repo.&lt;/p&gt;




&lt;h3&gt;
  
  
  Remove a worktree (cleanup 🧹)
&lt;/h3&gt;

&lt;p&gt;When you're done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree remove ../my-repo-hotfix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cleans Git metadata&lt;/li&gt;
&lt;li&gt;Safely removes the worktree&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ Avoid deleting the folder manually.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common pitfalls &amp;amp; gotchas ⚠️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One branch = one worktree&lt;/li&gt;
&lt;li&gt;You can't check out the same branch twice&lt;/li&gt;
&lt;li&gt;Don't delete worktrees manually&lt;/li&gt;
&lt;li&gt;Always use &lt;code&gt;git worktree remove&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shared files&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;node_modules&lt;/code&gt;, build outputs may need isolation&lt;/li&gt;
&lt;li&gt;Consider &lt;code&gt;.env.local&lt;/code&gt; or per-worktree configs&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;IDE awareness&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Your editor might open multiple projects&lt;/li&gt;
&lt;li&gt;This is usually a feature, not a bug 😉&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  When git worktree shines — and when it doesn't ✨
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It shines when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You juggle features and hotfixes&lt;/li&gt;
&lt;li&gt;You're frequently interrupted&lt;/li&gt;
&lt;li&gt;You work on large repos&lt;/li&gt;
&lt;li&gt;You want clean mental separation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;It may not be worth it when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The repo is tiny&lt;/li&gt;
&lt;li&gt;You only do one task at a time&lt;/li&gt;
&lt;li&gt;You're still learning Git fundamentals&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion &amp;amp; takeaways 🎯
&lt;/h2&gt;

&lt;p&gt;git worktree isn’t a niche feature.&lt;br&gt;
It’s a productivity multiplier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaways:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop stashing just to switch context&lt;/li&gt;
&lt;li&gt;Work on multiple branches at the same time&lt;/li&gt;
&lt;li&gt;Keep your flow, keep your sanity&lt;/li&gt;
&lt;li&gt;Clean, explicit, parallel work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you try it, going back to constant stashing feels… painful.&lt;/p&gt;

&lt;p&gt;If this article helped you, try git worktree on your next interruption&lt;br&gt;
and let me know how it changed your workflow 👇&lt;/p&gt;

</description>
      <category>git</category>
      <category>productivity</category>
      <category>workflow</category>
      <category>devtools</category>
    </item>
  </channel>
</rss>
