Skip to content

Diff of a selected directory doesn't show its new files, but space stages them #6246

Backlog

Description

@MartinCura

Written by Claude after discussing, reviewed it before posting. If you don't like this kind of report i can close it.

Describe the bug

When I select a directory in the Files panel, the main view shows the changes to the tracked files inside it, but not the new (untracked) files. If I then press space, the new files get staged too. So it's easy to stage files you never saw in the diff.

It looks like the same problem as #4245, which #4386 fixed for the "only tracked files" filter. Here there's no filter involved.

To Reproduce

  1. In a repo, change a tracked file in a directory, for example d/old.txt.
  2. Create a new file in the same directory: d/new.txt.
  3. Open lazygit and select d in the Files panel. The diff only shows the change to d/old.txt.
  4. Press space. Both files are staged, including d/new.txt.

Expected behavior

The diff for a directory shows everything that pressing space will stage. New files would appear as new-file diffs, the same way they do when you select a single untracked file.

(Making space skip the untracked files would also remove the surprise, but then there'd be no easy way to stage a whole directory with its new files.)

Version info:

  • commit=v0.65.0, build date=2026-09-07T11:03:19Z, build source=binaryRelease, version=0.65.0, os=linux, arch=amd64, git version=2.55.0

Terminal info:

Ghostty 1.3.1. I don't think it's terminal-related.

Additional context

I haven't built master, but reading the code there: for a directory, WorktreeFileDiffCmdObj runs git diff -- <dir>, and the --no-index /dev/null form is only used when the selected node is a single untracked file. So untracked files under a directory never make it into the diff. That code is the same as in 0.65.0.

Activity

  1. stefanhaller commented on Nov 25, 2026

    @stefanhaller
    Collaborator

    I sometimes find this confusing myself; for example when you only have one directory with a single untracked file: select the file and you see its diff, press up once to select the directory, and the diff is empty. That is a bit weird.

    On the other hand, we can't make the change you are suggesting. It is the expected behavior only for the case that you just created a new file and want to stage it. But sometimes I have untracked files sitting there in my working copy and I have no intention to commit them; e.g. notes that I'm taking during development, or an agent plan, or sometimes tool artefacts that I don't bother git-ignoring. I totally don't want any of these to show up in the diff when I select the / directory to see all my changes.

    This is a dilemma for which I can't think of a good solution; but I feel the current behavior is the best we can do. I also don't see it as so much of a usability problem as you make it sound: after you press space, you do see the added files in the diff, so you can still double-check that what you are committing looks right.

  2. MartinCura commented on Nov 26, 2026

    @MartinCura
    Author

    Very reasonable, yes, i agree. I don't suppose we could make it some kind of toggle or user option? Such as: i'm reviewing a whole dir and i press a certain key and now the diff includes all files inside it. I usually review a semi-specific dir, and my dev artifacts are normally elsewhere.

    It's not a huge deal, again, but i did find it misleading because my LLM authored some changes and i had missed the new files when reviewing.

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions