Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set vscode/gitlens as the default editor for git in wsl

Problem

When I start an interactive rebase from a windows cmd, the interactive gitlens rebase window pops up on vscode. When I do the same from wsl, the plain txt rebase file shows up on vscode.
Is there a way to make it so that when I rebase from the wsl, the gitlens rebase shows up?

Steps to reproduce

I Installed wsl with:

wsl --install

Then I selected the default:

wsl --setdefault Ubuntu

I then installed git again on the wsl with:

$ sudo apt-get install git

I then tried to set vscode as the default editor:

$ git config --global core.editor "/mnt/c/Users/user/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code --wait"

I got the vscode path by running:

$ Which code
like image 860
nick zoum Avatar asked Oct 15 '25 19:10

nick zoum


2 Answers

I would recommend following a process similar to this article which involve:

  • installing the "remote development" extension
  • Close out of the VSCode instance you were just using to install the Remote Development extension, and bring up your Linux terminal (WSL).
  • Run the command: cd; code . (space dot)
  • Search for GitLens in the extensions, and click "Install in WSL: Ubuntu-20.04"

After installing GitLens on WSL, you should see the same interactive rebase window as when you use Git from CMD.

like image 165
VonC Avatar answered Oct 18 '25 11:10

VonC


I had the same problem, and I fixed it with quotation marks.

So instead of

editor = /mnt/c/Users/myuser/AppData/Local/Programs/Microsoft VS Code/bin/code --wait

I had to put the following in my .gitconfig:

editor = \"/mnt/c/Users/myuser/AppData/Local/Programs/Microsoft VS Code/bin/code\" --wait

The path had to be surrounded by quotation marks.

EDIT:

It seems to be enough, when you just put `code` there, like this:

editor = code --wait

That's even easier and you don't need the path. :)

like image 24
B34v0n Avatar answered Oct 18 '25 09:10

B34v0n



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!