I find that I run in to this problem about every other month or so -- just long enough to forget how to solve it.

Here is the situation:

  • I have local changes
  • editor tools can point out which lines have changes
  • my cat replacement (bat), shows the changed lines

The Problem:

  • git diff and git status report no local changes
  • creating new files also do not show up in git diff and git status

This leads to me being unable to create a commit.

What I expect:

  • git status to show changed files, and the new file, if I make one
  • git diff should only show changed tracked files (it wouldn't report new / untracked files by default)

Things I've verified:

  • The working directory of both the copy of the repo with the file changes and the terminal where I'm checking git status are the same (sometimes it's easy to forget you can be in two very similar directories (but not exactly) when using worktrees) -- this is verified because bat shows line-wise git information in the gutter.

The fix

git update-index --no-assume-unchanged ./file1
git update-index --no-assume-unchanged ./file2

# for every package.json
git update-index --no-assume-unchanged  $(git ls-files | grep package.json)

# for all files 
# (for large repos we can't use the above command because 
#   update-index has a limit on the number of args passed)
#
# NOTE: this can be very slow
for file in $(git ls-files); do
  git update-index --no-assume-unchanged $file
done

On the repo I have at work where I run in to this problem, I have to do the above fix in every worktree and commit.

It seems once I commit in a particular worktree, git starts tracking files automatically again.

of note, the work computer:

  • is macOS 15.3.2, but I observed this behavior on 14.x, as well
  • has various security tools on it, but they've been changed out a number of times, so I don't think I can blame a specific one
  • git is installed via homebrew
  • permanently in clamshell mode (laptops are notoriously not good at this -- especially macOS)

On Linux, I also make heavy use of worktrees, but have not run in to this problem -- but it's hard to compare

  • no XProtect (mac's default security software part of "System Integrity Protection")
  • I manage the system myself
  • I don't use clamshell (I use my linux laptop as an actual laptop, and my linux desktop... has no clamshell mode haha)