title: Git: swap the main working tree with a linked working tree?
body: <p>I'm trying to find out if there's any way to swap working trees. My company has a lot of scripts that assume a specific directory structure, so to be able to work with multiple working trees, I would need the "new" linked worktree to take the place of the main worktree. </p>
  
  <p>I found <a href="https://git-scm.com/docs/git-worktree" rel="noreferrer"><code>git worktree move &lt;worktree&gt; &lt;new-path&gt;</code></a> but that doesn't allow "main" working trees to be moved, so there's no chance of swapping.</p>
  
  <p>Ideally, there would be a <code>git worktree swap &lt;worktree&gt; &lt;path&gt;</code> where:</p>
  
  <ul>
  <li>if <code>&lt;path&gt;</code> is a worktree, it swaps them</li>
  <li>if <code>&lt;path&gt;</code> is a commit-ish, it adds a new worktree with <code>&lt;worktree&gt;</code>'s name for the commit-ish, then swaps them</li>
  </ul>