mark working directory as safe with git #814
                
     Merged
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Add safe.directory for /var/www/html to silence Git’s “dubious ownership” warnings in Sail images
This PR adds one line to each Sail PHP Dockerfile (8.0–8.4):
Why this is needed
When working inside Sail containers, Git often prints the warning:
fatal: detected dubious ownership in repository at '/var/www/html'
This is noisy and distracting during normal local development (e.g., running Composer scripts or simple git status), because the container’s active user/UID may not match the on-disk ownership of /var/www/html. Marking the working directory as a safe Git directory removes the warning without changing how folks use Sail day-to-day.
What causes the “dubious ownership” warning
In April 2022, Git shipped a security fix hardening for CVE-2022-24765. As part of that fix, Git refuses to operate in a repository if the current user differs from the repository owner, unless the path is explicitly trusted via the safe.directory setting. This protects users on multi-user systems from configs/hooks in repos they don’t own.
The behavior is documented in Git’s manuals: by default, Git will not run in repos owned by someone else; you can opt-in specific paths with safe.directory.
In containerized dev environments this mismatch is common (different UIDs inside the container vs. the mounted volume), which is why Sail users see the warning frequently.
Why this is safe for Sail
Sail is explicitly a local development environment—not a production runtime—and is intended to help developers get a Laravel app running with Docker on their own machine. Marking /var/www/html (the working dir inside Sail) as “safe” only suppresses the ownership check for that one path inside the container. It does not weaken Git’s checks globally, nor does it add any new privileges; it simply acknowledges that this specific, local dev path is trusted.