Skip to content

Commit c280bd2

Browse files
marcvigclaude
andcommitted
Add Worktrees section to Git cheatsheet
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1737381 commit c280bd2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,17 @@ <h1>Git &amp; GitHub Cheatsheet</h1>
735735
</table>
736736
</div>
737737

738+
<div class="card" data-tab="git">
739+
<div class="card-header green">Worktrees</div>
740+
<table>
741+
<tr data-tip="Creates a new working directory linked to the repo with the specified branch checked out — lets you work on two branches simultaneously without stashing" data-example="git worktree add ../hotfix origin/hotfix"><td>git worktree add &lt;path&gt; &lt;branch&gt;</td><td>Check out a branch in a new directory</td></tr>
742+
<tr data-tip="Creates a new branch and checks it out in a new directory in one step — ideal for starting a feature or hotfix while keeping your current work untouched" data-example="git worktree add -b hotfix-123 ../hotfix main"><td>git worktree add -b &lt;branch&gt; &lt;path&gt;</td><td>Create new branch in new directory</td></tr>
743+
<tr data-tip="Lists all worktrees for the repo including the main one, showing their paths, HEAD commits, and branches" data-example="git worktree list"><td>git worktree list</td><td>List all linked worktrees</td></tr>
744+
<tr data-tip="Deletes the worktree directory and removes it from Git's tracking — the branch itself is not deleted" data-example="git worktree remove ../hotfix"><td>git worktree remove &lt;path&gt;</td><td>Remove a worktree</td></tr>
745+
<tr data-tip="Removes stale worktree entries left behind when directories were manually deleted rather than via git worktree remove" data-example="git worktree prune"><td>git worktree prune</td><td>Clean up stale worktree references</td></tr>
746+
</table>
747+
</div>
748+
738749
<div class="card" data-tab="git">
739750
<div class="card-header blue">Diffs &amp; Logs</div>
740751
<table>

0 commit comments

Comments
 (0)