Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a Windows GUI editor launched from WSL as git core.editor doesn't work #2867

Closed
kallja opened this issue Jan 22, 2018 · 3 comments
Closed

Comments

@kallja
Copy link

kallja commented Jan 22, 2018

I'm running Microsoft Windows [Version 10.0.16299.192]

I've set up git editor under WSL with the following comand:
git config --global core.editor "'/mnt/c/Program Files/Sublime Text 3/subl.exe' -w"

I then cd myself into a local git repository in /mnt/c/Users/username/git/repo and run:
git rebase -i

Sublime Text 3 is launched, but WSL hands it a path argument it can't work with:
/mnt/c/Users/username/git/repo/.git/rebase-merge/git-rebase-todo
instead of the expected:
C:\Users\username\git\repo\.git\-rebase-merge\git-rebase-todo.
subl

Is there a facility to translate paths in WSL to their Windows counterparts dynamically?

@benhillis
Copy link
Member

benhillis commented Jan 22, 2018

Yes, there is a tool called wslpath that should be available in your build. /bin/wslpath

wslpath usage:
    -a    force result to absolute path format
    -u    translate from a Windows path to a WSL path (default)
    -w    translate from a WSL path to a Windows path
    -m    translate from a WSL path to a Windows path, with ‘/’ instead of ‘\\’

    EX: wslpath ‘c:\users’

@imrimt
Copy link

imrimt commented Apr 16, 2024

@benhillis I'm unclear on what are you suggesting here? I'm running into this as well and would love to understand what the workaround is

@yincrash
Copy link

yincrash commented Nov 4, 2024

@imrimt

  1. Create a shell script named wsl_git_editor.sh containing:
#!/bin/bash

WINDOWS_PATH=$(wslpath -w "$1")

"/mnt/c/Program Files/Sublime Text/subl.exe" -w "$WINDOWS_PATH"
  1. Make the script executable with chmod +x wsl_git_editor.sh.
  2. Add the script to your global config: git config --global core.editor <file-location>/wsl_git_editor.sh

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

No branches or pull requests

4 participants