multiple-worktrees
worktree
primary worktree on main + 3 linked worktrees on feature/hotfix branches
Description
A repository with multiple linked worktrees, each on a different branch. The primary worktree is on `main` with a baseline commit. Three linked worktrees exist at temp paths: - `feat/alpha` — one commit ahead of main - `feat/beta` — two commits ahead of main - `hotfix/urgent` — one commit ahead of main Useful for testing: - worktree list views - branch switching when worktrees lock branches - tools that detect and display linked worktrees - the "branch is checked out in another worktree" error case
Contracts
- main is checked out in the primary worktree
- 3 linked worktrees exist
- feat/alpha has 1 commit ahead of main
- feat/beta has 2 commits ahead of main
- hotfix/urgent has 1 commit ahead of main
Tags
Branches
feat/alphafeat/betahotfix/urgentmain Use it
import { spinUpScenario } from '@gfargo/git-scenarios'
const repo = await spinUpScenario('multiple-worktrees') npx git-scenarios create multiple-worktrees import { describeWithScenario } from '@gfargo/git-scenarios/jest'
describeWithScenario('multiple-worktrees', (getRepo) => {
it('should have the expected state', async () => {
const repo = getRepo()
// your assertions here
})
}) Commit graph
* c4f2fe0 (hotfix/urgent) fix: critical hotfix
| * 9c01773 (feat/beta) feat: beta part 2
| * afd85cf feat: beta part 1
|/
| * e586e91 (feat/alpha) feat: alpha feature
|/
* f53cf2e (HEAD -> main) chore: initial scaffold