Von Gast (nicht überprüft) , 29 April 2026

Das Problem, das Worktrees losen

Sie sind tief in einem Feature, als ein dringender Bug-Report eintrifft.

Worktree hinzufugen

git worktree add ../hotfix-1234 hotfix/login-redirect
git worktree add -b hotfix/login-redirect ../hotfix-1234 main

Auflisten und verwalten

git worktree list
git worktree remove ../hotfix-1234
git worktree prune

Wie es intern funktioniert

Das .git in Ihrem Originalverzeichnis ist das echte Repo.

Konkrete Workflows

Hotfix ohne Storung

git worktree add ../hotfix main
cd ../hotfix
git checkout -b hotfix/cve-fix
cd -
git worktree remove ../hotfix

Lang laufender Vergleich

git worktree add ../old v2.4.0
diff -ru ../old/src ./src

PR eines Kollegen reviewen

gh pr checkout 123 --branch pr-123
git worktree add ../pr-123 pr-123
cd ../pr-123
npm test

CI und Worktrees

git worktree add ./build-linux $SHA
git worktree add ./build-windows $SHA

Limitierungen

  • Derselbe Branch kann nicht in zwei Worktrees ausgecheckt werden.
  • Einige Hooks konnen sich falsch verhalten.
  • Submodule in Worktrees konnen uberraschend sein.

Hilfreiche Aliase

[alias]
    wt = worktree
    wtl = worktree list
    wta = worktree add
    wtr = worktree remove