sublime_merge
sublime_merge copied to clipboard
Unsafe Repo after Sublime Merge update
Version info
- OS: Windows 10
- Build: 2071
Description
This installation is Sublime Merge installed on the Windows system with the git repositories living on the WSL. Everything worked fine yesterday and after installing the update to Sublime Merge this morning I get an error
"fatal: unsafe repository ('//wsl$/Ubuntu/home/...) To add an exception for this directory, call: git config --global --add safe.directory ..."
I tried running that on both the Windows and Linux versions of git that are installed with no change. Then I noticed Sublime Merge is using the bundled git. I don't see how to add that config setting to the bundled git.
Changing the git version to "wsl git" returns the error message: "CreateProcess failed: The system cannot find the file specified"
Changing the git version to "\wsl$\Ubuntu\usr\bin\git" changes the error message to "CreateProcess failed: $1 is not a valid Win32 application"
Steps to reproduce
Steps to reproduce the behavior:
- Have a working Sublime Merge installation on Windows 10 with repositories on WSL
- Update to build 2071
- Attempt to interact with the remote repo (pull, checkout, etc)
- Get failure
Expected behavior
I would expect git commands to work correctly
Hi @NathanDeckinga,
Thanks for reporting this issue - this is due to a recent update of Git (see https://github.blog/2022-04-12-git-security-vulnerability-announced/). We're in the process of adding a dialog to mark "unsafe" repositories as safe - this will be available in the next Sublime Merge build.
In the meantime, you can work around this issue by switching to the System git binary via the Sublime Merge preferences dialog (under the advanced section) and then running git config --global --add safe.directory ... via the command line (where ... is the path to your repository).
It's worth noting you can also mark all repositories as safe using git config --global safe.directory "*" as described in the above link.
Thanks, - Dylan from Sublime HQ
git config --global safe.directory '*'
Just a fyi. If the user executes that command under cmd.exe (powershell is fine), it ignores folders whose name satisfies glob '*' rather than *. Double quoted git config --global safe.directory "*" would be a more general command I think.
Thanks @jfcherng - updated the above comment :)
Hi @dpjohnst, just a note concerning what you said here:
We're in the process of adding a dialog to mark "unsafe" repositories as safe - this will be available in the next Sublime Merge build.
I've just encountered the new dialog you mention (I'm on build 2074) and it doesn't seem to have correctly added the configuration for the repository I was browsing, which happened to be on a Windows fileshare.
I was going to create a bug report but first searched around and found this thread. If you think it's better that I create a bug report for this, I can do that as well.
Details of the issue:
After clicking "mark as safe", the Sublime Merge command history shows that it ran the following command:
git config --global --add safe.directory $'/\\servername/d$/PATH/TO/GIT_REPO'
However, the next command (git fetch) failed with the following error message:
warning: encountered old-style '/\servername/d$/PATH/TO/GIT_REPO' that should be '%(prefix)//\servername/d$/PATH/TO/GIT_REPO'
fatal: unsafe repository ('//servername/d$/PATH/TO/GIT_REPO' is owned by someone else)
To add an exception for this directory, call:
git config --global --add safe.directory '%(prefix)///servername/d$/PATH/TO/GIT_REPO'
So I pasted the command git config --global --add safe.directory '%(prefix)///servername/d$/PATH/TO/GIT_REPO' in Git Bash, and this resolved the problem.
FYI, here are the two gitconfig entries that were created:
[safe]
directory = /\\servername/d$/PATH/TO/GIT_REPO
directory = %(prefix)///servername/d$/PATH/TO/GIT_REPO
The first one being the one created by Sublime Merge, and the second entry being the one that I had to create myself.
On my setup using a mounted windows share / server directory as "local" location:
"server.name.tld/Share" is mounted as T:
Using the new built-in dialog generates:
C:\Users\username>git config --global --add safe.directory T:/Projects/.../repo-folder
Wheras only manually changing the command to the following works:
C:\Users\username>git config --global --add safe.directory T://server.name.tld/Share/Projects/.../repo-folder
If I rely on the built-in dialog I just get re-promted over and over again...
Reproduced this just now on a fresh install of Build 2077. I'm also getting this warning.
No issues once running git config --global --add safe.directory #...; I'm using Git for Windows 2.37.3. So there doesn't seem to be any disparity between Sublime's and Windows's Git config (like other people seem to be experiencing) on my end. However, the %(prefix) warning still pops up.
Any other diagnostic info that would be helpful to provide?
I'm encountering the same warning, followed by files being unstaged when attempting to stage files on WSL with Sublime Merge for Windows.

There is a lot to take in with that dialogue.
- Since the operation fails, shouldn't it be an error, and not a warning?
- It talks about two different git repo's even though I am only doing an operation on 1 repo (and to my knowledge I only have one repo open in Sublime Merge)
- Where am I supposed to run this command? in WSL? On Windows? In Sublime?
- What does
%(prefix)mean? Do I write that literally or is it a stand-in for a prefix? - The warning is ephemeral - how do I select the text and copy-paste it?
System: Windows 10 Enterprise, version 21H1, 19043.2130 Sublime Merge, Stable Channel, version 2077
@olsgaard, I'm going to try to answer these without being a Windows or WSL user:
- Since the operation fails, shouldn't it be an error, and not a warning?
The Sublime Merge aspect of the failed git command is the orange failed: text and anything outside the yellow box. The text you see in the yellow box is the output from git itself. Based on what I see, git is giving you two items to look at: the warning line (next answer below) & the fatal lines (this issue's topic).
- It talks about two different git repo's even though I am only doing an operation on 1 repo (and to my knowledge I only have one repo open in Sublime Merge)
This has to do with the warning vs fatal lines. Not knowing which (if either) is the current repo, I can't know for sure.
The required fix is the fatal part, you can read Dylan's first comment for details as to why & below for possible help on fixing it. I think the warning isn't an immediate problem, but I think you'll see it for all commands or this repo's commands until taken care of, see below. After this point, I can only speculate.
- Where am I supposed to run this command? in WSL? On Windows? In Sublime?
Best guess: in the WSL terminal (maybe Git Bash, but I think that is non-WSL?) If you know: wherever you have run git commands prior to Sublime Merge.
- What does %(prefix) mean? Do I write that literally or is it a stand-in for a prefix?
I'm not 100% sure about this, but it appears to be specific to git support for repos in WSL: https://stackoverflow.com/questions/70998844/git-warning-encountered-old-style-home-user-gitignore-that-should-be-pre
- The warning is ephemeral - how do I select the text and copy-paste it?
Click the [>!] to the left of the orange failed: text. This will show the command history, the first item is usually what you want & the right side is copyable.
Notes:
- any
gitaction you perform will be added to that history, you may have to find the correct historical item - the clickable icon will be
[>✓]if the most recent command is successful
Overall Notes:
- Sublime Merge strives to be a thin UI layer on top of
git, with the same (in general) commands & behaviors; see theReal Gitsection of the homepage. Therefore, it is useful to either already know some of git or to know how to investigate git related issues and (potentially) fix them. - The Sublime Forums will likely get you quicker responses than this issue tracker if you run into issues related to Sublime Merge or SM+git. We're not always git (or WSL) experts, so Stack Overflow or other forums specific to git (or WSL) can be better.