George George - 2 months ago 6
Git Question

`git status` shows worktree folders

I have created a worktree in my git project (feature of git >= 2.5). It resides in a sub folder of the root project folder and is called

wt-something
.

Now when I issue
git status
from within the root project folder the worktree folder is shown among other untracked files as
untracked file
.

Isn't it supposed the worktree folders not to be shown in git status?

Or I do have to specify them explicitly in
.gitignore
?

Answer

Git Worktree works by creating a new subfolder which acts like a new branch. This folder contains, among other things, a .git file for the worktree branch. When you type git status the worktree folder shows up under untracked files. This makes sense, because from the point of view of your current branch, the worktree is just a bystander with no direct influence.

Untracked files will not prevent you from doing any work (push, pull, etc.) on your current main branch.

Comments