{
    "archive_path": "archive/1789121093.365453",
    "base_url": "emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit",
    "basename": "",
    "bookmarked_date": "2026-09-11 10:04",
    "canonical": {
        "archive_org_path": "https://web.archive.org/web/emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit",
        "dom_path": "output.html",
        "favicon_path": "favicon.ico",
        "git_path": "git/",
        "google_favicon_path": "https://www.google.com/s2/favicons?domain=emacsredux.com",
        "headers_path": "headers.json",
        "htmltotext_path": "htmltotext.txt",
        "index_path": "index.html",
        "media_path": "media/",
        "mercury_path": "mercury/content.html",
        "pdf_path": "output.pdf",
        "readability_path": "readability/content.html",
        "screenshot_path": "screenshot.png",
        "singlefile_path": "singlefile.html",
        "warc_path": "warc/",
        "wget_path": "emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/index.html"
    },
    "domain": "emacsredux.com",
    "extension": "",
    "hash": "1G6808CSTJ8RCM8ECT51",
    "history": {
        "archive_org": [],
        "dom": [],
        "favicon": [
            {
                "cmd": [
                    "curl",
                    "--silent",
                    "--location",
                    "--compressed",
                    "--max-time",
                    "120",
                    "--output",
                    "favicon.ico",
                    "--user-agent",
                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 ArchiveBox/0.7.4 (+https://github.com/ArchiveBox/ArchiveBox/) curl/curl 8.14.1 (x86_64-pc-linux-gnu)",
                    "https://www.google.com/s2/favicons?domain=emacsredux.com"
                ],
                "cmd_version": "curl 8.14.1 (x86_64-pc-linux-gnu)",
                "end_ts": "2026-09-11T10:08:37.611689+00:00",
                "index_texts": null,
                "output": "favicon.ico",
                "pwd": "/data/archive/1789121093.365453",
                "schema": "ArchiveResult",
                "start_ts": "2026-09-11T10:08:37.150470+00:00",
                "status": "succeeded"
            }
        ],
        "git": [],
        "headers": [
            {
                "cmd": [
                    "curl",
                    "--silent",
                    "--location",
                    "--compressed",
                    "--head",
                    "--max-time",
                    "120",
                    "--user-agent",
                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 ArchiveBox/0.7.4 (+https://github.com/ArchiveBox/ArchiveBox/) curl/curl 8.14.1 (x86_64-pc-linux-gnu)",
                    "https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"
                ],
                "cmd_version": "curl 8.14.1 (x86_64-pc-linux-gnu)",
                "end_ts": "2026-09-11T10:08:37.882563+00:00",
                "index_texts": null,
                "output": "headers.json",
                "pwd": "/data/archive/1789121093.365453",
                "schema": "ArchiveResult",
                "start_ts": "2026-09-11T10:08:37.620485+00:00",
                "status": "succeeded"
            }
        ],
        "htmltotext": [],
        "media": [],
        "mercury": [
            {
                "cmd": [
                    "/app/node_modules/@postlight/parser/cli.js",
                    "https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"
                ],
                "cmd_version": "1.0.0",
                "end_ts": "2026-09-11T10:08:43.422805+00:00",
                "index_texts": null,
                "output": "mercury",
                "pwd": "/data/archive/1789121093.365453",
                "schema": "ArchiveResult",
                "start_ts": "2026-09-11T10:08:40.310395+00:00",
                "status": "succeeded"
            }
        ],
        "pdf": [],
        "readability": [
            {
                "cmd": [
                    "/app/node_modules/readability-extractor/readability-extractor",
                    "/tmp/tmp6t_2w4uz",
                    "https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"
                ],
                "cmd_version": "0.0.11",
                "end_ts": "2026-09-11T10:08:40.301180+00:00",
                "index_texts": [
                    "I\u2019ll admit that until fairly recently I had no idea git worktrees existed.\nThey\u2019ve been part of git for a decade1 and I never once needed them. Feature\nbranches did the job just fine - create a branch, do the work, merge it, delete\nit, and start over.\n\nWhat finally introduced me to worktrees was, of all things, AI coding agents.\nTools like Claude Code create a worktree for each task, so several agents (or\nseveral sessions of the same agent) can work on the same repo in parallel\nwithout stepping on each other - or on you. Suddenly my projects directory was\nfull of cider-this and cider-that siblings, and I figured I should\nunderstand what\u2019s actually going on there.\n\n\n\nWorktrees vs Branches\n\nA branch is just a movable pointer to a commit, and making one is basically\nfree. The catch is that a repository has a single working directory, so working\non two branches means switching that directory back and forth. You know the\nroutine: stash your half-done work (or commit it), check out the other branch,\ndo the thing, check out the first branch again, unstash. It works, but it\u2019s\ntedious, and it gets worse when the two branches leave your project in\ndifferent build states and every switch means recompiling half the world.\n\nA worktree gives you an additional working directory attached to the same\nrepository:\n\n$ git worktree add ../cider-smart-targeting -b smart-form-targeting\n\n\nNow ~/projects/cider-smart-targeting is a full checkout of that branch, while\nyour main checkout stays exactly where it was. The object database, refs,\nstashes and remotes are all shared - a worktree is not a clone, so fetching in\none is fetching in all, and creating one is nearly instant. Each worktree gets\nits own HEAD and index, and git enforces one simple rule: a branch can only\nbe checked out in one worktree at a time.\n\nWhen are they worth it? Whenever two things need to happen at the same time: a\nlong test run on one branch while you work on another, reviewing a PR without\ndisturbing your half-done work, or - the reason everyone is talking about them\nthese days - AI agents doing their thing in isolation. The price is pretty\nmodest: your working files exist on disk more than once, and anything that\nisn\u2019t tracked by git (dependencies, build caches, node_modules and friends)\nhas to be set up again in each worktree.\n\nIf branches have never felt limiting to you, that\u2019s fine - they didn\u2019t for me\neither, for over a decade. Worktrees are one of those features you don\u2019t miss\nuntil your workflow changes.\n\nWhat About Jujutsu?\n\nWhile we\u2019re on the topic of working copies - the most interesting thing\nhappening in version control right now is\nJujutsu (jj), a git-compatible VCS that makes\nthe problem worktrees solve mostly go away. In jj the working copy is a\ncommit, snapshotted automatically as you work. There\u2019s no staging area and no\nstash, because there\u2019s no uncommitted state that could be lost or get in the\nway - switching contexts is always safe. It also has proper support for\nparallel working directories (jj workspace), plus an operation log that makes\npractically everything undoable. That last bit is part of why the AI agent\ncrowd has taken an interest in it too.\n\nYou can use jj on top of an existing git repository (they call this a colocated\nrepo), and your colleagues - and Magit - will keep seeing a normal git repo.\nI\u2019m still just an observer here, but it\u2019s clearly a project to keep an eye on.\n\n\n\nBack to Emacs land. Magit has had worktree support for years, hiding behind Z:\n\n\n  \n    \n      Key\n      Command\n      Description\n    \n  \n  \n    \n      Z b\n      magit-worktree-checkout\n      Check out an existing branch in a new worktree\n    \n    \n      Z c\n      magit-worktree-branch\n      Create a new branch and worktree in one go\n    \n    \n      Z g\n      magit-worktree-status\n      Jump to another worktree\u2019s status buffer\n    \n    \n      Z m\n      magit-worktree-move\n      Move a worktree\n    \n    \n      Z k\n      magit-worktree-delete\n      Delete a worktree\n    \n  \n\n\nThe best part is that there\u2019s nothing else to learn. Each worktree gets its own\nMagit status buffer, and every Magit command operates on the worktree the\ncurrent buffer belongs to. Z g is the only switching mechanism you need, and\neven that is just a shortcut for visiting another status buffer.\n\nA few practical tips from my (admittedly recent) experience:\n\n\n  By default the status buffer doesn\u2019t list your worktrees. Fix that with:\n\n\n(magit-add-section-hook 'magit-status-sections-hook\n                        #'magit-insert-worktrees\n                        nil t)\n\n\nNow every status buffer shows all worktrees of the repo, and you can hit\n  RET on any of them to jump there.\n\n\n  \n    Create worktrees as siblings of the main checkout with descriptive names\n(cider-smart-targeting next to cider), not nested inside it - nesting\nconfuses grep, find and plenty of other tools.\n  \n  \n    Magit\u2019s branch selection annotates branches that are checked out in another\nworktree with the worktree\u2019s path, and refuses to check them out a second\ntime (that\u2019s git\u2019s rule, not Magit being difficult). If you ever wondered why\na branch \u201cwon\u2019t check out\u201d, that\u2019s usually why.\n  \n  \n    Each worktree is its own project as far as project.el (or Projectile) is\nconcerned, so project switching, per-project buffers and search all work\nnaturally.\n  \n  \n    Anything that\u2019s not tracked by git doesn\u2019t come along for the ride. You\u2019ll\nhave to install dependencies once per worktree and start with a cold build\ncache. For Elisp that costs you nothing; for a big JVM or JS project it\u2019s the\nmain downside of the whole approach.\n  \n  \n    When you\u2019re done with a worktree, delete it with Z k (or with\ngit worktree remove from the command line). If you just delete the\ndirectory by hand, git worktree prune will clean up the leftover\nbookkeeping.\n  \n\n\nClosing Thoughts\n\nThese days my workflow with agents usually looks like this: an agent does its\nwork in a worktree, I review the changes there in Magit (often while another\ntask is running in a second worktree), and the worktree goes away once the\nbranch is merged. Maybe one day I\u2019ll find other uses for worktrees - we\u2019ll see.\n\nAre you using git worktrees - and did you discover them the same roundabout way\nI did? I\u2019d love to hear about it in the comments!\n\nThat\u2019s all I have for you today. Keep hacking (in parallel)!"
                ],
                "output": "readability",
                "pwd": "/data/archive/1789121093.365453",
                "schema": "ArchiveResult",
                "start_ts": "2026-09-11T10:08:38.547074+00:00",
                "status": "succeeded"
            }
        ],
        "screenshot": [],
        "singlefile": [],
        "title": [
            {
                "cmd": [
                    "curl",
                    "--silent",
                    "--location",
                    "--compressed",
                    "--max-time",
                    "120",
                    "--user-agent",
                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 ArchiveBox/0.7.4 (+https://github.com/ArchiveBox/ArchiveBox/) curl/curl 8.14.1 (x86_64-pc-linux-gnu)",
                    "https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"
                ],
                "cmd_version": "curl 8.14.1 (x86_64-pc-linux-gnu)",
                "end_ts": "2026-09-11T10:08:38.539847+00:00",
                "index_texts": null,
                "output": "Working with Git Worktrees in Magit | Emacs Redux",
                "pwd": "/data/archive/1789121093.365453",
                "schema": "ArchiveResult",
                "start_ts": "2026-09-11T10:08:38.528580+00:00",
                "status": "succeeded"
            }
        ],
        "wget": [
            {
                "cmd": [
                    "wget",
                    "--no-verbose",
                    "--adjust-extension",
                    "--convert-links",
                    "--force-directories",
                    "--backup-converted",
                    "--span-hosts",
                    "--no-parent",
                    "-e",
                    "robots=off",
                    "--timeout=120",
                    "--restrict-file-names=windows",
                    "--warc-file=/data/archive/1789121093.365453/warc/1789121317",
                    "--page-requisites",
                    "--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 ArchiveBox/0.7.4 (+https://github.com/ArchiveBox/ArchiveBox/) wget/GNU Wget 1.21.3",
                    "--compression=auto",
                    "https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"
                ],
                "cmd_version": "GNU Wget 1.21.3",
                "end_ts": "2026-09-11T10:08:38.519458+00:00",
                "index_texts": null,
                "output": "emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/index.html",
                "pwd": "/data/archive/1789121093.365453",
                "schema": "ArchiveResult",
                "start_ts": "2026-09-11T10:08:37.892057+00:00",
                "status": "succeeded"
            }
        ]
    },
    "icons": null,
    "is_archived": true,
    "is_static": false,
    "latest": {
        "archive_org": null,
        "dom": null,
        "favicon": "favicon.ico",
        "git": null,
        "media": null,
        "pdf": null,
        "screenshot": null,
        "singlefile": null,
        "title": "Working with Git Worktrees in Magit | Emacs Redux",
        "warc": null,
        "wget": "emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/index.html"
    },
    "link_dir": "/data/archive/1789121093.365453",
    "newest_archive_date": "2026-09-11T10:08:40.310395+00:00",
    "num_failures": 0,
    "num_outputs": 6,
    "oldest_archive_date": "2026-09-11T10:08:37.150470+00:00",
    "path": "/blog/2026/09/02/working-with-git-worktrees-in-magit/",
    "schema": "Link",
    "scheme": "https",
    "snapshot_id": "62da1ccf-81a5-4c90-b389-30b1004e9bc6",
    "sources": [
        "/data/sources/1789121093-import.txt"
    ],
    "tags": null,
    "tags_str": "",
    "timestamp": "1789121093.365453",
    "title": "Working with Git Worktrees in Magit | Emacs Redux",
    "updated": "2026-09-11T10:08:37.150028+00:00",
    "updated_date": "2026-09-11 10:08",
    "url": "https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"
}