Wsl linux не выполняется git clone

Содержание
  1. Get started using Git on Windows Subsystem for Linux
  2. Git can be installed on Windows AND on WSL
  3. Installing Git
  4. Git config file setup
  5. Git Credential Manager setup
  6. Adding a Git Ignore file
  7. Git and VS Code
  8. Git line endings
  9. приступая к работе с Git на подсистема Windows для Linux
  10. Git можно установить на Windows и в WSL
  11. Установка Git
  12. Настройка файла конфигурации Git
  13. Установка диспетчера учетных данных Git
  14. Добавление файла игнорирования Git
  15. Git и VS Code
  16. Окончания строк Git
  17. [WSL2] Can’t update Ubuntu, git clone, apt install, but ping works (Windows 1909) #5971
  18. Comments
  19. TheoForay commented Sep 23, 2020
  20. Environment
  21. Steps to reproduce
  22. therealkenc commented Sep 23, 2020
  23. TheoForay commented Sep 28, 2020
  24. ttelfer commented Oct 2, 2020
  25. maxlieblich commented Oct 3, 2020
  26. zhangshengsheng commented Oct 10, 2020
  27. ad-on-is commented Oct 27, 2020
  28. patrickhoebeke commented Oct 28, 2020
  29. shiv-sid commented Oct 31, 2020
  30. robpomeroy commented Nov 9, 2020
  31. robpomeroy commented Nov 9, 2020 •
  32. Thadir commented Nov 10, 2020
  33. trallnag commented Nov 15, 2020
  34. mickael-h commented Nov 22, 2020
  35. jacobbaek commented Nov 24, 2020
  36. ad-on-is commented Nov 24, 2020
  37. jacobbaek commented Nov 25, 2020
  38. osmanatam commented Nov 25, 2020
  39. trallnag commented Nov 25, 2020 •
  40. adam-grant-hendry commented Nov 25, 2020
  41. jacobbaek commented Nov 30, 2020
  42. dan640 commented Nov 30, 2020 •
  43. hallownfs commented Dec 13, 2020
  44. lukee1234 commented Dec 14, 2020
  45. robpomeroy commented Jan 5, 2021
  46. eldano1995 commented Jan 8, 2021 •
  47. exowanderer commented Feb 2, 2021

Get started using Git on Windows Subsystem for Linux

Git is the most commonly used version control system. With Git, you can track changes you make to files, so you have a record of what has been done, and have the ability to revert to earlier versions of the files if needed. Git also makes collaboration easier, allowing changes by multiple people to all be merged into one source.

Git can be installed on Windows AND on WSL

An important consideration: when you enable WSL and install a Linux distribution, you are installing a new file system, separated from the Windows NTFS C:\ drive on your machine. In Linux, drives are not given letters. They are given mount points. The root of your file system / is the mount point of your root partition, or folder, in the case of WSL. Not everything under / is the same drive. For example, on my laptop, I’ve installed two version of Ubuntu (20.04 and 18.04), as well as Debian. If I open those distributions, select the home directory with the command cd

, and then enter the command explorer.exe . , Windows File Explorer will open and show me the directory path for that distribution.

Linux distro Windows Path to access home folder
Ubuntu 20.04 \\wsl$\Ubuntu-20.04\home\username
Ubuntu 18.04 \\wsl$\Ubuntu-18.04\home\username
Debian \\wsl$\Debian\home\username
Windows PowerShell C:\Users\username

If you are seeking to access the Windows file directory from your WSL distribution command line, instead of C:\Users\username , the directory would be accessed using /mnt/c/Users/username , because the Linux distribution views your Windows file system as a mounted drive.

You will need to install Git on each file system that you intend to use it with.

Installing Git

Git comes already installed with most of the Windows Subsystem for Linux distributions, however, you may want to update to the latest version. You also will need to set up your git config file.

To install Git, see the Git Download for Linux site. Each Linux distribution has their own package manager and install command.

For the latest stable Git version in Ubuntu/Debian, enter the command:

You also may want to install Git for Windows if you haven’t already.

Git config file setup

To set up your Git config file, open a command line for the distribution you’re working in and set your name with this command (replacing «Your Name» with your preferred username):

Set your email with this command (replacing «youremail@domain.com» with the email you prefer):

If you don’t yet have a GitHub account, you can sign-up for one on GitHub. If you’ve never worked with Git before, GitHub Guides can help you get started. If you need to edit your Git config, you can do so with a built-in text editor like nano: nano

Git Credential Manager setup

Git Credential Manager (GCM) Core enables you to authenticate a remote Git server, even if you have a complex authentication pattern like two-factor authentication, Azure Active Directory, or using SSH remote URLs that require an SSH key password for every Git push. GCM Core integrates into the authentication flow for services like GitHub and, once you’re authenticated to your hosting provider, requests a new authentication token. It then stores the token securely in the Windows Credential Manager. After the first time, you can use Git to talk to your hosting provider without needing to re-authenticate. It will just access the token in the Windows Credential Manager.

To set up GCM Core for use with a WSL distribution, open your distribution and enter this command:

If you intend to work with Azure Repos, some additional configuration is required:

Now any git operation you perform within your WSL distribution will use GCM Core. If you already have credentials cached for a host, it will access them from the credential manager. If not, you’ll receive a dialog response requesting your credentials, even if you’re in a Linux console.

If you are using a GPG key for code signing security, you may need to associate your GPG key with your GitHub email.

Adding a Git Ignore file

We recommend adding a .gitignore file to your projects. GitHub offers a collection of useful .gitignore templates with recommended .gitignore file setups organized according to your use-case. For example, here is GitHub’s default gitignore template for a Node.js project.

If you choose to create a new repo using the GitHub website, there are check boxes available to initialize your repo with a README file, .gitignore file set up for your specific project type, and options to add a license if you need one.

Git and VS Code

Visual Studio Code comes with built-in support for Git, including a source control tab that will show your changes and handle a variety of git commands for you. Learn more about VS Code’s Git support.

Git line endings

If you are working with the same repository folder between Windows, WSL, or a container, be sure to set up consistent line endings.

Since Windows and Linux use different default line endings, Git may report a large number of modified files that have no differences aside from their line endings. To prevent this from happening, you can disable line ending conversion using a .gitattributes file or globally on the Windows side. See this VS Code doc about resolving Git line ending issues.

Источник

приступая к работе с Git на подсистема Windows для Linux

Git — это наиболее часто используемая система управления версиями. С помощью Git вы можете отслеживание изменений, внесенных в файлы, поэтому у вас есть запись о том, что было сделано, и возможность вернуться к более ранним версиям файлов при необходимости. Кроме того, Git упрощает совместную работу, позволяя объединить изменения, внесенные несколькими людьми, в один источник.

Git можно установить на Windows и в WSL

важное замечание: при включении WSL и установке дистрибутива Linux устанавливается новая файловая система, отделенная от Windows NTFS C:. диск на компьютере. В Linux буквы дисков не задаются. Они получают точки подключения. Корневой каталог файловой системы / — это точка подключения корневого раздела или папки в случае с WSL. Не все в разделе / — это один и тот же диск. Например, на моем ноутбуке я установил две версии Ubuntu (20,04 и 18,04), а также Debian. при открытии этих дистрибутивов выберите корневой каталог с командой cd

, а затем введите команду explorer.exe . , Windows откроется проводник, и отобразится путь к каталогу для этого дистрибутива.

Дистрибутив Linux Windows Путь к домашней папке Access
Ubuntu 20.04 \\wsl$\Ubuntu-20.04\home\username
Ubuntu 18.04 \\wsl$\Ubuntu-18.04\home\username
Debian \\wsl$\Debian\home\username
Windows PowerShell C:\Users\username

если вы ищете доступ к каталогу файлов Windows из командной строки распространения WSL, вместо доступа к C:\Users\username каталогу будет получен доступ с помощью /mnt/c/Users/username , поскольку дистрибутив Linux просматривает Windowsную файловую систему в качестве подключенного диска.

Необходимо установить Git в каждой файловой системе, с которой планируется использовать.

Установка Git

Git уже установлен с большинством подсистема Windows для Linux дистрибутивов, однако может потребоваться обновление до последней версии. Вам также потребуется настроить файл конфигурации Git.

Сведения об установке Git см. на сайте скачивания Git для Linux . Каждый дистрибутив Linux имеет собственный диспетчер пакетов и команду install.

Для получения последней стабильной версии Git в Ubuntu/Debian введите команду:

также может потребоваться установить Git для Windows , если вы этого еще не сделали.

Настройка файла конфигурации Git

Чтобы настроить файл конфигурации Git, откройте командную строку, в которой вы работаете, и задайте свое имя с помощью этой команды (заменив «Ваше имя» на предпочитаемое имя пользователя):

Задайте свою электронную почту с помощью этой команды (заменив » youremail@domain.com » своим предпочтительным письмом):

если у вас еще нет учетной записи GitHub, вы можете зарегистрироваться на нее GitHub. Если вы никогда не использовали Git, обратитесь к руководствам по GitHub. Они помогут вам приступить к работе. Если вам нужно изменить конфигурацию Git, это можно сделать с помощью встроенного текстового редактора, например Nano: nano

Установка диспетчера учетных данных Git

ядро диспетчера учетных данных git (GCM) позволяет проверять подлинность удаленного сервера Git, даже если имеется сложная модель проверки подлинности, например двухфакторная проверка подлинности, Azure Active Directory или использование удаленных url-адресов ssh, требующих пароля ключа ssh для каждой принудительной отправки Git. ядро GCM интегрируется в поток проверки подлинности для таких служб, как GitHub, а после проверки подлинности в поставщике услуг размещения запрашивает новый маркер проверки подлинности. после этого маркер сохраняется в диспетчере учетных данных Windowsв безопасном режиме. В первый раз можно использовать Git для взаимодействия с поставщиком услуг размещения, не требуя повторной проверки подлинности. Он просто обратится к маркеру в диспетчере учетных данных Windows.

Чтобы настроить ядро GCM для использования с дистрибутивом WSL, откройте дистрибутив и введите следующую команду:

если вы планируете работать с Azure Repos, требуется дополнительная настройка :

Теперь любая операция Git, выполняемая в дистрибутиве WSL, будет использовать GCM Core. Если у вас уже есть кэшированные учетные данные для узла, к ним будет выполняться доступ из диспетчера учетных данных. В противном случае отобразится диалоговое окно с запросом учетных данных, даже если вы работаете в консоли Linux.

если вы используете ключ GPG для защиты подписывания кода, вам может потребоваться связать ключ GPG с GitHub электронной почтой.

Добавление файла игнорирования Git

Рекомендуется добавить gitignore- файл в проекты. GitHub предлагает набор полезных шаблонов. gitignore с рекомендуемыми настройками файлов gitignore, организованными в соответствии с вашим вариантом использования. например, вот GitHub шаблон gitignore по умолчанию для проекта Node.js.

если вы решили создать репозиторий с помощью веб-сайта GitHub, доступны флажки для инициализации репозитория с файлом README,. gitignore-файлом, настроенным для конкретного типа проекта, и вариантами добавления лицензии, если это необходимо.

Git и VS Code

Visual Studio Code поставляется со встроенной поддержкой Git, включая вкладку управления исходным кодом, в которой будут отображаться изменения и работать с различными командами Git. дополнительные сведения о поддержке Git VS Code.

Окончания строк Git

если вы работаете с одной и той же папкой репозитория между Windows, WSL или контейнером, обязательно настройте согласованные окончания строк.

поскольку Windows и Linux используют разные концы строк по умолчанию, Git может сообщить о большом количестве измененных файлов, которые не отличаются от их концов строк. чтобы предотвратить это, можно отключить преобразование конца строки с помощью .gitattributes файла или глобально на Windows стороне. см. этот VS Code документ об устранении проблем с завершением строк Git.

Источник

[WSL2] Can’t update Ubuntu, git clone, apt install, but ping works (Windows 1909) #5971

Comments

TheoForay commented Sep 23, 2020

Environment

Steps to reproduce

sudo apt update , or git clone XXX can’t connect.
sudo apt update :

I checked ipconfig on PowerShell, and my vEthernet adapter for WSL isn’t disconnected, and I can confirm that, as ping 8.8.8.8 actually works.

The text was updated successfully, but these errors were encountered:

therealkenc commented Sep 23, 2020

Please collect WSL logs and post the backlink to the feedback item here. Also please identify any third-party networking software that has been installed on Windows.

TheoForay commented Sep 28, 2020

I would really like to follow the procedure to give more intel but unfortunately I don’t have the Feedback Hub on my computer. I don’t find a way to install it.
Perhaps it’s because it’s on my company’s laptop.
Is there another I can provide you what you need?

ttelfer commented Oct 2, 2020

Having the exact same problem.

maxlieblich commented Oct 3, 2020

Having the same problem. Things work fine when I reboot the computer, but after a while WSL 2 loses its connection to certain things (apt, mainly) while ping still works fine. Here’s my feedback backlink: https://aka.ms/AA9tug5

zhangshengsheng commented Oct 10, 2020

ad-on-is commented Oct 27, 2020

For me, even ping stopped working

patrickhoebeke commented Oct 28, 2020

I had exactly the same issue (Windows 10 version 1903 (build 18362.1139) + Ubuntu 18.04 though WSL2) . It turns out that my wifi was configured in Windows as «public» network. Switching to «private» fixed the problem.
Hope this can help

shiv-sid commented Oct 31, 2020

I had exactly the same issue (Windows 10 version 1903 (build 18362.1139) + Ubuntu 18.04 though WSL2) . It turns out that my wifi was configured in Windows as «public» network. Switching to «private» fixed the problem.
Hope this can help
Excellent @patrickhoebeke . This worked for me.

robpomeroy commented Nov 9, 2020

Subscribing. Initially ping to Ubuntu mirrors worked, but apt update didn’t (timeout). Then finally ping stopped working too (destination unreachable).

WSL rendered unusable. Pity. Back to Hyper-V VMs (with a custom NAT vSwitch to overcome spurious WiFi adapter issues). >sigh

robpomeroy commented Nov 9, 2020 •

Update: downgrading to WSL 1 seems to be the best option for now, while the WSL 2 bugs are ironed out?
wsl —list —verbose

wsl —set-version [distro name] 1

Thadir commented Nov 10, 2020

I did a downgrade installed stuff I needed upgraded back. But yeah WSL 2 seems to be broken for now.

trallnag commented Nov 15, 2020

Same for me. For now I’m going back into my «normal» VM :/

mickael-h commented Nov 22, 2020

Same problem for me. I had to downgrade back to WSL 1.

jacobbaek commented Nov 24, 2020

Same problem for me. Is there any workaround except downgrading back to WSL 1?

ad-on-is commented Nov 24, 2020

Guys, check your firewall-settings. For me, Bitdefender Firewall blocks WSL2 traffic.

jacobbaek commented Nov 25, 2020

@ad-on-is Thanks, I checked the firewall that i used at the desktop, this caused from firewall liked you mentioned.
I thought it is strange why ICMP is working despite other all traffics are not working. but when i disabled the firewall policy, it is working and also checked the deny log in firewall log.
Thanks again.

osmanatam commented Nov 25, 2020

i am living the same problem. in wsl1 update is working , in wsl22 update problem. any solution.

trallnag commented Nov 25, 2020 •

@osmanatam add two rules to your firewall that all through the network interface used by WSL2, it is worth a try.

adam-grant-hendry commented Nov 25, 2020

Same problem for me

jacobbaek commented Nov 30, 2020

Guys, check to firewall.
WSL1 and WSL2 have different network interfaces.
WSL1’s network interfaces is that shared with host network, on the other hands WSL2 network interfaces has only one network intetface that works as NAT.
So WSL1 can access where the host can access. But WSL2 can not access where the host can access.

dan640 commented Nov 30, 2020 •

This fixed the issue for me #5867 (comment)

EDIT: This just fixed it temporary. The issue is back. Apparently when the network configuration changes (VPN off and then on again) then WSL2 cannot find its way to the internet anymore.

hallownfs commented Dec 13, 2020

sudo ifconfig eth0 mtu 1350
using this fixed the issue for me
source : #4253

lukee1234 commented Dec 14, 2020

If you modified, moved or compressed the temp folder, look at #5437 for the solution

robpomeroy commented Jan 5, 2021

sudo ifconfig eth0 mtu 1350
using this fixed the issue for me
source : #4253

Me also. So WSL 2 causes packet fragmentation?

eldano1995 commented Jan 8, 2021 •

Checkout my comment: maybe it helps: #5061 (comment)

exowanderer commented Feb 2, 2021

Update: downgrading to WSL 1 seems to be the best option for now, while the WSL 2 bugs are ironed out?
wsl —list —verbose

wsl —set-version [distro name] 1

I tried and tried and tried to configure my firewalls to let the WSL2 work it’s magic. I followed several tutorials that all led to the same

5 ways to config the firewalls.

In the end, I set WSL version back to 1; and it worked as though ‘nothing was wrong’.

Источник

Читайте также:  Epson l3151 driver linux
Оцените статью