What does "warning: Git tree '/a/path' is dirty" mean exactly?

Thanks for the extra info! When I was looking around online, every mention I found was in the context of flakes (e.g., Flakes: why do I consistently see warnings about the git tree being dirty?).

For completeness sake, I stumbled upon it while playing with builtins.fetchGit to see what happens fetching local repos of varying internal states, and when the repo was “dirty”, the builtin’s behaviour would change:

  • The currently checked-out branch in the my-project repo is feature, with only a couple untracked files, but in otherwise pristine state, and the command below indeed retrieves the snapshot at the HEAD of feature:

    nix-repl> builtins.fetchGit ~/clones/my-project
    
    { lastModified     = 1651372838;
      lastModifiedDate = "20220501024038";
      narHash          = "sha256-ejxD1ZjnbRBsvi5NJYhLPQ9FGgORFD/kH10boQxqjVI=";
      outPath          = "/nix/store/x6zcxzmjc340n5ycmgqylvw1j2pg0jkn-source";
      rev              = "f9af46639a9bb5fb22705ebdfd25783866e22c0f";
      revCount         = 36;
      shortRev         = "f9af466";
      submodules       = false;
    }
    
  • In contrast, the current working directory here is a clone of the nixos/nix repo on a branch containing my very in-progress experimental changes:

    nix-repl> builtins.fetchGit {url=./.;}
    
    warning: Git tree '/home/toraritte/clones/nix' is dirty
    { lastModified     = 1658169134; 
      lastModifiedDate = "20220718183214";
       narHash         = "sha256-Vw4lSkslmDIRcHQEO7uSiEV53vYJszVWXeHmFE4/Pww="; 
       outPath         = "/nix/store/74b2zy6vrh463mrbr4p7mwrvjg75967b-source";
       rev             = "0000000000000000000000000000000000000000";
       revCount        = 0;
       shortRev        = "0000000"; 
       submodules      = false; 
    }
    
1 Like