Getting Started Git Basics Worktree

Worktree

Learn what the Git worktree is.

The worktree is the current set of files on disk for the repository you have checked out.

In simpler terms, it is the version of the project you can see and edit in your editor right now.

What belongs to the worktree

The worktree includes:

  • Files that already belong to the repository.
  • New files you have created but not committed yet.
  • Files you have modified or deleted locally.

When you open a repository folder, you are looking at its worktree. If you type in a file, save a file, rename something, or delete something, those changes first happen in the worktree.

Worktree vs repository history

It helps to separate the files on disk from the saved history in Git.

The repository includes the commit history and Git data. The worktree is just the current checkout of files from that repository, plus any local edits you have made since the last commit.

That means:

  • The worktree can contain unfinished changes.
  • The repository history contains saved commits.
  • Changing a file does not immediately change Git history.

Until you stage and commit your edits, they are only local worktree changes.

How the worktree relates to the staging area

The worktree and the staging area are closely related, but they are not the same thing.

The worktree holds everything you have changed on disk. The staging area holds only the changes you have selected for the next commit.

For example:

Worktree
  file-a.txt   modified
  file-b.txt   modified
  file-c.txt   modified
       |
       | stage file-b.txt
       v
Staging area
  file-b.txt   staged

Still only in worktree
  file-a.txt   unstaged
  file-c.txt   unstaged

This separation is what lets Git build a commit from only part of your current work.

Why a clean worktree matters

A clean worktree means there are no uncommitted local changes.

That matters because some Git actions are safer or simpler when the worktree is clean. For example, switching branches, rebasing, or pulling changes is easier when Git does not need to worry about local edits being overwritten or mixed into another task.

Worktree in GitComet

In GitComet, the worktree is what you usually notice first when files have changed.

GitComet can show you:

  • Which files are changed in your worktree.
  • Which changes are still unstaged.
  • Which changes have already been staged for commit.
  • Diffs that compare the worktree to the staged state or committed state.

Documentation

Search

move open Esc close

Browse the docs or start typing to filter results.