4

As explained here, on Windows Subsystem for Linux I can do many many things using the command line. I am wondering if it is possible to install Git. I have tried using

sudo apt-get install git

but the result is:

~$ sudo apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package git

Some suggestions?

Leos313
  • 1,926

1 Answers1

8

You might need to add the package first:

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
Baa
  • 3,452
  • 3
    I didn't need to do step 1 to get get installed on WSL Ubuntu 18.04, but until I did, I could only get git 2.17 despite 2.27 being latest at time of this comment. Thanks! – Dan Jun 10 '20 at 18:15
  • I had the exact same problem. I followed the steps at https://unix.stackexchange.com/a/324629/210901 sudo add-apt-repository ppa:git-core/ppa -y && sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git -y in case it goes away. – Relequestual Feb 20 '21 at 08:43
  • This is helpful for WSL2 too. WSL2 comes with focal and git 2.25.1. While that version may be sufficient for some users, the others get use the git-core PPA to upgrade git to the latest version. For example, I needed the latest git-p4.py, which required a newer git. – Ferdinand Prantl Jul 02 '22 at 09:35