{
  "id": 16825267,
  "title": "What is a git worktree: how it works and when to use one",
  "url": "https://urgent.news/2026/10/28/what-is-a-git-worktree-how-it-works-and-when-to-use-one",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-28T01:00:07.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/devrchancay/what-is-a-git-worktree-how-it-works-and-when-to-use-one-9nl"
  },
  "original_language": "en",
  "account": "A git worktree is an extra working directory that shares the same repository, branch, and configuration with the original directory. This feature allows users to work on different tasks or branches simultaneously without the need to clone the repository again or use the stash command frequently. Git worktrees have been available since git 2.5 (2015), but their usefulness is best understood once one knows how repositories are structured internally.\n\nA git repository consists of three main components: the object database, references, and the working state. The object database stores every commit, tree, and file content of the repository's history (located in the .git/objects folder). References, such as branches and tags, point to specific commits within the history (found in .git/refs and .git/packed-refs). Lastly, the working state includes the currently checked-out branch (HEAD), the index (staged changes), and the files visible in the folder (located in .git/HEAD, .git/index, and the working directory).\n\nThe object database and references are shared across all worktrees, while the working state is unique to each worktree. This means that each worktree has its own HEAD, index, and folder of files, but they all have access to the same object database and references. The main worktree is the original folder where the repository was cloned or initialized, and it cannot be removed or moved using the git worktree command. Linked worktrees, on the other hand, are additional working directories created with the git worktree add command and behave similarly to the main worktree, except they cannot be removed or moved using git worktree.",
  "summary": "A git worktree is an additional working directory of the same repository: a second folder with its own files, its own checked-out branch and its own staging area, which shares the history, the branches and the configuration with the original folder. With it you can have main open in one folder and feature/login in another at the same time, without cloning the repository twice and without running…",
  "key_points": [
    "Git worktree shares repository, branch, and config with main directory",
    "Object database and references are common across all worktrees",
    "Each worktree has unique working state with own HEAD, index, files"
  ],
  "editors_take": "Utilizing multiple working directories allows developers to manage several branches simultaneously without the overhead of redundant clones or the constant interruption of stashing active changes.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}