detected dubious ownership in repository

Fix Git 'dubious ownership' error on Windows in 3 steps

Git on Windows throws this when file ownership doesn't match. The fastest fix is usually changing the repo's owner in Windows security settings. Here's how to do it and two other fixes.

Cause #1: The repository folder's owner isn't your user account

The most common reason Git throws this error on Windows is that the repository folder (or one of its parent folders) is owned by a different user account than the one you're running Git from. This happens a lot when you move a repo from another machine, clone it onto an external drive, or unzip a project that was created on a different computer.

Here's the error you'll see:

fatal: detected dubious ownership in repository at 'C:/Users/you/project'
'C:/Users/you/project' is owned by:
        'S-1-5-32-544'
but the current user is:
        'S-1-5-21-...'

That long string starting with S-1-5 is a Windows security identifier (SID). When Git sees that the owner of the folder isn't the same as the current user, it refuses to run because it's worried about symlink attacks or other security tricks.

How to fix it

The proper fix is to take ownership of the folder with your current user account. Here's the step-by-step:

  1. Open File Explorer and go to the folder that contains your Git repo (the folder that has the .git subfolder).
  2. Right-click the folder and select Properties.
  3. Go to the Security tab.
  4. Click the Advanced button (it's at the bottom).
  5. You'll see a box that says "Owner: ...". On the right, click Change.
  6. In the "Enter the object name to select" field, type your Windows username. If you're not sure, type Everyone — that works in a pinch, but it's better to use your own account.
  7. Click Check Names, then OK.
  8. Check the box that says Replace owner on subcontainers and objects. This makes sure it also fixes any subfolders.
  9. Click OK until you're back to the Properties window.
  10. Click OK to close Properties.

After you do that, go back to your terminal and run your Git command again. It should work now. If you still get the error, try closing your terminal and reopening it—sometimes the Git process caches the old state.

One thing to note: if the repo is on a network drive or a removable drive, the owner change might not stick. In that case, use the next fix.

Cause #2: Git's safe.directory setting is missing

If changing ownership doesn't fix it, or you can't change ownership (like on a company-managed laptop), the next option is to tell Git to trust that specific folder. Git has a setting called safe.directory that lets you whitelist directories that are owned by other users.

You can add your repo to the safe list with this command:

git config --global --add safe.directory C:/path/to/your/repo

Make sure you use forward slashes and the full path to the repo folder. You can copy the path from the error message—just replace the backslashes with forward slashes.

If that works, but you have many repos scattered around, you can add a wildcard path:

git config --global --add safe.directory *

But be careful with that. That tells Git to trust everything, which defeats the purpose of the check. I only recommend it on a personal machine where you're the only user and you trust all the folders on your system. On a work machine, that's a big no-no.

After you run the command, try your Git command again. The error should be gone.

Cause #3: The repo was copied from Linux/Mac with different file permissions

Sometimes you copy a repo from a Linux or Mac machine to Windows, and the files carry over with ownership information that doesn't make sense in Windows. Git sees that weird ownership and throws the dubious ownership error.

The fix here is a bit more aggressive: copy the repo again, but make sure you remove the .git folder and reinitialize it. Or, if you don't need the history, just copy the files and run git init to start fresh.

But if you need the history, do this:

  1. Copy the repo to your Windows machine (if you haven't already).
  2. Open Git Bash or the terminal in the repo's root folder.
  3. Run this to remove the current .git folder:
rm -rf .git

This is a destructive command—it wipes all your commit history. Only do this if you have the original repo elsewhere or you've pushed everything to a remote.

  1. Then initialize a new repo:
git init

Then add your remote and push if needed. That resets the ownership to your current user.

That's the nuclear option. Do it only if the first two fixes don't work and you're sure you have a backup.

Quick reference

CauseFixWhen to use
Folder owner mismatchChange owner via Properties → Security → AdvancedMost common, do this first
Missing safe.directoryRun git config --global --add safe.directory <path>Can't change owner or owner change didn't help
Ownership metadata from other OSDelete .git and reinitLast resort, only with backup

Try the first fix. Most of the time that's all you need. If it doesn't work, move down the list. And remember, if you're on a company laptop, talk to your IT team before changing folder ownership—they might have a group policy that's causing this.

Related Errors in Programming & Dev Tools
ERESOLVE npm ERESOLVE: The Real Fix for Dependency Tree Errors 0XC0000416 Fixing STATUS_INSUFFICIENT_RESOURCE (0xC0000416) – Desktop Heap Error Module not found: Error: Can't resolve Fix Webpack 'Module not found: Error: Can't resolve' after upgrade 0X40000022 Fixing STATUS_WX86_EXCEPTION_CHAIN (0x40000022) on x64 Windows

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.