Closed tianvan closed 5 years ago
This was fast. The thing literally came out yesterday for everyone.
Actually, it's still not yet out, so support for this will take its time.
It would be great to use Bash on Ubuntu on Windows as the integrated terminal! Not to mention its git installation for the git tab. I can't +1 this enough! :)
Noticed that we can use the Bash on Ubuntu on Windows terminal in the integrated terminal now. That's awesome! Now we just need the git integration with the git version installed through bash on ubuntu on windows.
+1
+1
+1
This would be great not just for git but for extensions as well. I use the vscode-go extension and it shells out to use the command line tools often. I'd like it if it could shell out to bash as opposed to windows terminal. It would also need access to environment variables from bash. Basically, I want it to think it is in a bash environment even though it is in windows.
Thanks.
+1
+1
+1
+1
+1
+1
+1
+1 :)
+1
@joaomoreno Wanted to check if there any work being done on this WSL git + VSCode integration?
With Insider's 1.19 from Nov 15th I was able to track git commits with having VSCode installed on Windows while having git installed on WSL and do basically everything except pull/push (due to VSCode not using SSH keys from WSL) without any configuration or hacks.
But, with today's Nov 20th update now it's complaining about the git.path
not finding a suitable version of git. However, it only checks Windows for a git installation instead of WSL.
Since this feature was working a few days ago, what should the new git.path
be set to in order to integrate with WSL's git? i tried all sorts of bash.exe related paths without success.
@nickjj Just set it to your Windows git.exe. VSCode never had support for WSL git. You can still use most of the features, but it will use the windows config not the WSL config.
@CoenraadS I never had Git installed on Windows (ever).
Prior to this patch, the editor was capable of showing changes in a repo when git was only installed on WSL.
Is there a way I can roll back to Nov 15th's release?
Prior to the latest insiders it checked the PATH, so if you do cmd -> where git.exe
you might be surprised.
where git.exe
returns nothing from PowerShell, because I don't have Git installed on Windows.
If I run which git
from WSL it's found at /usr/bin/git
.
I discovered this great project: https://github.com/andy-5/wslgit for people who want this support today.
ping @joaomoreno because maybe this would be an interesting route for VSCode team to think about.
+1
+1 Integrating this feature make web coding on Windows perfect.
+1
+1
Hey everyone, friendly reminder to use the thumbs up reaction to the original comment instead of everyone posting +1. :) That's how interest is gauged, not by the number of comments with +1 which is harder to quantify. (Also doesn't spam everyone's notifications) ;)
So with the new year, is there a native solution yet? Or is wslgit still the best workaround for now?
Looks like this hasn’t made it to the roadmap. :cry:
Im workin in this !
Just a naïve approach: I tried installing Git for windows, then added the Program Files/Git/bin
to my path and created an alias for git.exe=git
(or you alias the exe
directly)
Since WSL can run windows binaries both (wsl.exe
/zsh
and vscode
integrated terminal) now use the windows git installation.
Maybe this helps and sorry if I got the problem wrong ^^
@erikmueller I believe this issue is for people who are using the WSL as their development environment and don't want to have to install Git for Windows in addition to WSL Git.
In other words, VSCode should be able to use WSL Git as it's SCM rather than requiring users to install additional software (Git for Windows).
It's worth noting that the integrated terminal can already use WSL Git, but that the SCM cannot.
I'm done with this but ... VSCode so hard to commit my code ... sad !
I modify child_process to get into bash.exe and run git ... convert every input path from win style to posix style. convert every result path from posix style to win style. Done ! git still working on my computer ... but i can't commit my work to repo ... i don't know why
@trickymast3r That's great news. Have you got a fork/PR everyone could take a look at? If you're struggling to submit a PR, take a look at the vscode contribution guide
@trickymast3r I had a similar thing going on in Node.js. I used pkg to package-up my git.js
file into a git.exe
file that ran a git.cmd
file with the following contents:
@echo off
wsl git %*
@echo on
Vscode isn't complaining that Git doesn't exist now, but it is complaining that there are "no active source control providers."
I also tried mklink git.exe git.cmd
. No 🎲🎲 !
Can someone please take this out of Backlog? It's fairly relevant. Especially if you want to entice Linux/macOS devs to use Windows...
Yes, was just struggling with this and am surprised to find it still not addressed. I'd really not have to maintain my ssh keys in two separate places with two installs of git. VS Code is great about working with WSL in so many ways, but this is still missing.
+1
@Cifram I've gotten away with one set of SSH keys by creating one in /mnt/
and using it in both WSL and Windows - maybe that's an option to explore? This doesn't remove the need to install Git on both WSL and Windows though.
I'm doing the same thing. I gave wslgit but it was far too slow to be usable.
Instead installed GIT on windows as well as WSL. Ssh keys are stored in wsl. A symlink/junction was created in windows to link to wsl. Your path will vary.
mklink /J C:\Users\{User}\.ssh C:\Users\{User}\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\{user}\.ssh
I have heard that editing linux files from windows can cause problems so changes to these ssh keys should probably only be made from WSL.
+1
+1
I've been looking into this and, I think, I made a little bit of progress. Maybe someone will be able to take this further.
The way it should work is to set "git.path": "wsl git"
in User Settings of VSC as this is the preferred way of running WSL commands [1]. However there seem to be a problem with node child_process when spawning a command with spaces (needs confirmation).
The quite obvious solution, as already suggested [2], is to create a cmd script:
@echo on
wsl git %*
@echo off
and then use it in User Settings; "git.path": "C:\\wsl\\git.cmd"
.
However there is some problem with that. Turns out that spawning a process which starts wsl, for some reason makes child_process to wait for an input. And that prevents VSC to finish the process of locating git executable.
I monkey-patched resources\app\extensions\git\out\git.js
function findSpecificGit
to ignore stdin
options = {stdio: ['ignore', null, null]};
const child = cp.spawn(path, ['--version'], options);
And that made VSC to successfully recognize git! But now there's an issue with recognizing git repository.
What VSC does, it goes through various directories, starting with project directory and executes command wsl git rev-parse --show-toplevel
which returns an absolute path to the git repository. But it returns it in Unix-lie format. And here I'm stuck.
[1] https://docs.microsoft.com/en-us/windows/wsl/interop#run-linux-tools-from-a-windows-command-line [2] https://github.com/Microsoft/vscode/issues/9502#issuecomment-364043243
@iksemot Not sure if this is what you're looking for, but since Windows 10 17046 there is a tool called wslpath
which will convert between windows/wsl paths. This will be included in the upcoming (April) release of Windows 10 (RS4).
This binary resides in the wsl bin, so perhaps something like this might work?
wsl wslpath -wa $(git rev-parse --show-toplevel)
That will convert the value returned by git to an absolute windows path.
On the issue of child_process
waiting for an input, does https://github.com/nodejs/node/issues/18431 seem to help?
So when are we getting a solution which is not a complete hack and just a setting?
👍
👍
What you can do is to first try wslpath
and if that fails you try a normal git
command. It's not ideal but it works.
See: Use WSL git inside VS Code from Windows 10 17046
UPDATED: as @mterrel already noticed the simple version was not able to add/stage files but more important also ls-tree
was not working. This is because all of these commands are called with a absolute path. I've updated my version of the git.bat
so it can handle calls with absolute paths
There is still one problem what is if you use a passphrase on you ssh for git it will not do any push, pull etc. from VS code. You will get a endless spinner because wsl
will show Enter passphrase for /home/user/.ssh/id_rsa
but this looks like a general problem of VS code with ssh and passphrase ( https://github.com/Microsoft/vscode/issues/13680 ) This is b.t.w. no problem if you add 'C:\Tools' to your PATH
because you can then just enter the passphrase