7

Suppose you're working on WSL cli bash, then you want to use gitk of the Windows on that current working dir, can you do this?

Regards,

3
  • 2
    If the path of gitk is C:\folder\gitk.exe convert it to /mnt/c/folder/gitk.exe and type it in wsl.
    – Biswapriyo
    Commented Aug 5, 2018 at 14:38
  • @Biswapriyo that's interesting, let me try when i got back
    – arvil
    Commented Aug 5, 2018 at 14:55
  • To get gitk working in WSL, this worked for me: gist.github.com/ojacques/…
    – Ryan
    Commented Jul 22, 2020 at 23:40

3 Answers 3

8

If you have Git for Windows installed, you can invoke gitk as gitk.exe directly from the WSL command line without needing to install any additional software.

The only caveat to this is that the Windows version of gitk doesn't understand WSL paths, only Windows ones. This means that you can only invoke gitk.exe from within your repository. In other words, if /mnt/c/Users/arvil/working/my-repo is a Git repo, the following work:

$ cd /mnt/c/Users/arvil/working/my-repo && gitk.exe
$ cd /mnt/c/Users/arvil/working/my-repo/src && gitk.exe

But invoking it from outside will not:

$ gitk.exe /mnt/c/Users/arvil/working/my-repo
$ cd /mnt/c/Users/arvil/another-repo && gitk.exe ../my-repo
$ cd /mnt/c/Users/arvil/working && gitk.exe my-repo  # even this fails!

Basically, if you need to pass a path to gitk, it won't work.

1
  • Try this gitk.exe $(wslpath -w /mnt/c/Users/arvil/working) command in WSL. For your commands, gitk.exe should be in %PATH% variable or one can add full path of gitk.exe.
    – Biswapriyo
    Commented Nov 16, 2019 at 4:46
6

I came here because I wanted to do the same. Though, after I finally successfully started the gitk binary, it obviously failed to find the source code, as the Windows binary doesn't know the file locations on the WSL format. I.e. my files in WSL are on /mnt/c/git/foobar.

You can probably make some symlinks or apply some other smart tricks to make the directory structure the same, but instead I went the other route; installing an X server on Windows and installing and elf-64 version of gitk. There are several options, but this is my working configuration:

  • installing VcXsrv from https://sourceforge.net/projects/vcxsrv/
    • during installation, I selected to set the X server to 0
  • start the XLaunch from Windows start menu
  • from Ubuntu on WSL,
    • sudo apt install gitk
    • echo export DISPLAY=:0 >> ~/.bashrc && source ~/.bashrc
    • cd /mnt/c/git/foobar && gitk --all
1
  • I didn't know about VcXsrv until now. But I'm very glad you mentioned it! Not sure why this answer isn't accepted; it does exactly what's requested.
    – dgw
    Commented Oct 4, 2019 at 12:06
0

If you have Windows 11, all you have to do is run:

sudo apt update
sudo apt install gitk

Works without jumping through hoops or installing an X Server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .