Git init не работает windows 10

I have an installation of Git for Windows, but when I try to use the git command in Command Prompt, I get the following error: 'git' is not recognized as an internal or external command, operable

Windows 7 32 — bit

I am using git for my Ruby on Rails application. First time so…

I created a .bat file for loading my RoR applications with the paths manually typed using this tutorial at «http://www.youtube.com/watch?v=-eFwV8lRu1w» If you are new to Ruby on Rails you might want to check it out as I followed all steps and it works flawlessly after a few trials and errors.

(The .bat file is editable using notepad++ hence no need for the long process whenever you need to edit a path, you can follow these simple process after creating a .bat file following the tutorials on the link above «file is called row.bat».)

  1. right click on the .bat file,
  2. edit with notepad++.
  3. find path.
  4. insert path below the last path you inputted.

    )
    During the tutorials I don’t remember anything said in regards to using the git command so when starting a new project I had this same problem after installing git. The main issue I had was locating the folder with the bin/git.exe (git.exe did not show up in search using start menu’s «search programs and files» ) NOTE I now understood that the location might vary drastically — see below.

To locate the bin/git.exe i followed this steps

1 left click start menu and locate ->> all programs ->> GitHub inc.
2 right click git shell and select open file location
3 click through folders in the file location for the folder «bin»

(I had 4 folders named
1. IgnoreTemplates_fdbf2020839cde135ff9dbed7d503f8e03fa3ab4
2. lfs-x86_0.5.1
3. PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad («bin/exe, found here <<-«)
4. PoshGit_869d4c5159797755bc04749db47b166136e59132
)

Copy the full link by clicking on the explorers url
(mine was «C:UsersusernameAppDataLocalGitHubPortableGit_c2ba306e536fdf878271f7fe636a147ff37326adbin») open .bat file in notepad++ and paste using instructions on how to add a path to your .bat file from tutorials above. Problem solved!

  • Remove From My Forums
  • Вопрос

  • Пытаюсь клонировать репозиторий https://github.com/SkyVVorker2770/CS_LABs.git встроенным в VS Git. 
    При клонировании возникает ошибка git failed with a fatal error invalid branch name: init defaultBranch =

    Прошу помощи в решении данного вопроса

Ответы

  • Здравствуйте,

    Попробуйте прописать:

    • git config --global init.defaultBranch main

    смотрите —
    Highlights from Git 2.28


    Если Вам помог чей-либо ответ, пожалуйста, не забывайте жать на кнопку «Предложить как ответ» или «Проголосовать за полезное сообщение» Мнения, высказанные здесь, являются отражение моих личных взглядов, а не позиции
    корпорации Microsoft. Вся информация предоставляется «как есть» без каких-либо гарантий.

    • Изменено

      26 октября 2021 г. 20:18

    • Предложено в качестве ответа
      Maksim MarinovMicrosoft contingent staff, Moderator
      27 октября 2021 г. 9:35
    • Помечено в качестве ответа
      dima040891
      27 октября 2021 г. 10:06

I have installed GIT. Then in command prompt(which was already open before installation of GIT) I navigated to the folder where GIT was installed. I typed git but showed ‘git’ is not recognised as an internal or external command. I re-opened cmd and again performed the same operation,this time it worked. My question is why it did not worked for the first time?

asked Mar 19, 2017 at 4:42

Arijit Basu's user avatar

1

The reason is this, as far as my knowledge goes when a command prompt window is opened it loads all the path variables and environment variables from the system. If a program modifies the variable after the command prompt is opened, those changes won’t be registered in the cmd window until you reopen it.

answered Mar 19, 2017 at 4:47

JWanniarachchi's user avatar

When git is installed it writes some enviromental variables which are not picked up by the cmd terminal until all cmd terminals are closed.

answered Mar 19, 2017 at 5:06

Peter Halligan's user avatar

1

To clarify and expand on the other answers, the PATH environment variable defines directories that will be searched when looking for executables (as in when you call git). This variable is declared when you open a command prompt, and this instance of PATH is not affected by git installation if it is done after the command prompt is opened. So there is no way for the command prompt to know what to execute when you call git, thus the error. If you had called it with the path (relative or absolute) to git, it would have executed fine.

Git installation modifies how PATH should be defined by adding the path to the git executable: C:Program FilesGitcmd. Only subsequent declarations of PATH (such as when you open another command prompt) will reflect these changes.

answered Mar 19, 2017 at 5:13

busybear's user avatar

busybearbusybear

9,8841 gold badge25 silver badges41 bronze badges

If you navigated to the installation folder in your command prompt then no, it shouldn’t have worked.

Since it didn’t, then everything seems OK to me.

The problem here is that the executables, such as git.exe is placed in a subfolder of the installation folder, named bin. Unless you navigate into that folder, git as a command won’t be found.

As all the other answers here mention, the reason it worked the next time was that the PATH variable that was configured by the installation did not take effect for the already open command prompt. As such, the next command prompt window you opened could execute git where it was, including inside the installation folder.

answered Mar 19, 2017 at 10:29

Lasse V. Karlsen's user avatar

Lasse V. KarlsenLasse V. Karlsen

375k100 gold badges627 silver badges818 bronze badges

I have installed GIT. Then in command prompt(which was already open before installation of GIT) I navigated to the folder where GIT was installed. I typed git but showed ‘git’ is not recognised as an internal or external command. I re-opened cmd and again performed the same operation,this time it worked. My question is why it did not worked for the first time?

asked Mar 19, 2017 at 4:42

Arijit Basu's user avatar

1

The reason is this, as far as my knowledge goes when a command prompt window is opened it loads all the path variables and environment variables from the system. If a program modifies the variable after the command prompt is opened, those changes won’t be registered in the cmd window until you reopen it.

answered Mar 19, 2017 at 4:47

JWanniarachchi's user avatar

When git is installed it writes some enviromental variables which are not picked up by the cmd terminal until all cmd terminals are closed.

answered Mar 19, 2017 at 5:06

Peter Halligan's user avatar

1

To clarify and expand on the other answers, the PATH environment variable defines directories that will be searched when looking for executables (as in when you call git). This variable is declared when you open a command prompt, and this instance of PATH is not affected by git installation if it is done after the command prompt is opened. So there is no way for the command prompt to know what to execute when you call git, thus the error. If you had called it with the path (relative or absolute) to git, it would have executed fine.

Git installation modifies how PATH should be defined by adding the path to the git executable: C:Program FilesGitcmd. Only subsequent declarations of PATH (such as when you open another command prompt) will reflect these changes.

answered Mar 19, 2017 at 5:13

busybear's user avatar

busybearbusybear

9,8841 gold badge25 silver badges41 bronze badges

If you navigated to the installation folder in your command prompt then no, it shouldn’t have worked.

Since it didn’t, then everything seems OK to me.

The problem here is that the executables, such as git.exe is placed in a subfolder of the installation folder, named bin. Unless you navigate into that folder, git as a command won’t be found.

As all the other answers here mention, the reason it worked the next time was that the PATH variable that was configured by the installation did not take effect for the already open command prompt. As such, the next command prompt window you opened could execute git where it was, including inside the installation folder.

answered Mar 19, 2017 at 10:29

Lasse V. Karlsen's user avatar

Lasse V. KarlsenLasse V. Karlsen

375k100 gold badges627 silver badges818 bronze badges

Содержание

  • 1 То, что вызывает «git», не распознается как внутренняя или внешняя ошибка команды
  • 2 Способ 1: повторно открыть командную строку
  • 3 Способ 2: использование автоматического способа добавления GIT-пути к переменным
  • 4 Способ 3: добавление переменной PATH вручную

Несколько пользователей сообщают о получении «Git’ не распознается как внутренняя или внешняя команда » ошибка при попытке запустить команду git в командной строке. Хотя некоторые пользователи сообщали, что эта проблема возникла через некоторое время после установки Git для Windows, другие сталкиваются с этой проблемой, как только установка Git завершена.

'git' is not recognized as an internal or external command, operable program or batch file. «Git» не распознается как внутренняя или внешняя команда,
работоспособная программа или командный файл.

То, что вызывает «git», не распознается как внутренняя или внешняя ошибка команды

Мы исследовали эту конкретную проблему, просмотрев различные пользовательские отчеты. Основываясь на наших исследованиях, существует несколько сценариев возникновения этой ошибки:

  • Git PATH не установлен (или неправильно) в Переменные — Недавнее программное обеспечение в самом программном обеспечении или ошибка пользователя, возможно, неправильно настроили Git PATH в скобках переменных.
  • CMD был открыт во время установки GIT — Если вы недавно установили Git для Windows во время открытия окна командной строки, проблема может быть решена, как только вы снова откроете командную строку.

Если вы пытаетесь решить эту конкретную проблему, эта статья предоставит вам несколько руководств по устранению неполадок. Ниже представлен набор методов, которые другие пользователи в аналогичной ситуации использовали для решения проблемы. Для достижения наилучших результатов следуйте приведенным ниже методам, пока не найдете исправление, эффективное для решения проблемы в конкретной ситуации.

Способ 1: повторно открыть командную строку

Если вы относитесь к парням (или девушкам) в терминале и постоянно держите окно CMD открытым (даже во время установки Git), проблема может возникнуть из-за того, что командная строка не была обновлена ​​с последними изменениями переменных.

Если этот сценарий применим к вам, исправить это так же просто, как закрыть окно CMD и открыть еще одно. Если путь был задан правильно, вы сможете использовать команды Git без получения «Git’ не распознается как внутренняя или внешняя команда » ошибка.

Если этот сценарий не применим к вашей ситуации, перейдите к следующему способу ниже.

Способ 2: использование автоматического способа добавления GIT-пути к переменным

Если вы хотите избежать возни с переменными PATH, вы можете решить «Git’ не распознается как внутренняя или внешняя команда » ошибка при использовании графического интерфейса установки Git для автоматического создания переменных Path для вас. Это позволит вам использовать Git как из Git Bash, так и из командной строки Windows.

Вот краткое руководство по удалению Git и настройке начальной установки для автоматического добавления переменных пути для вас:

  1. Нажмите Windows ключ + R открыть диалоговое окно «Выполнить». Затем введите «appwiz.cplИ нажмите Войти открыть Программы и особенности окно.
    Диалог запуска: appwiz.cplДиалог запуска: appwiz.cpl
  2. внутри Программы и особенности, найдите запись Git, щелкните по ней правой кнопкой мыши и выберите Удалить. Затем следуйте инструкциям на экране, чтобы удалить текущую установку Git.
    Удалите текущую версию GitУдалите текущую версию Git
  3. Перезагрузите компьютер, чтобы завершить процесс удаления.
  4. Посетите эту ссылку (Вот) и загрузите последнюю версию Git для Windows. Загрузка должна начаться автоматически. Если это не так, просто нажмите на версию, связанную с вашей битовой архитектурой ОС.
    Загрузка установочного исполняемого файла GitЗагрузка установочного исполняемого файла Git
  5. Откройте исполняемый файл установки и следуйте инструкциям по установке. Вы можете оставить все параметры для значений по умолчанию. Когда вы доберетесь до настройки среды PATH, убедитесь, что вы выбрали Использовать Git из командной строки Windows переключения.
    Выберите «Использовать Git» в командной строке Windows.Выберите «Использовать Git» в командной строке Windows.
  6. Продолжите настройку установки, оставив выбранные значения по умолчанию (или выберите свои собственные), затем щелкните устанавливать кнопка.
    Установка Git для WindowsУстановка Git для Windows
  7. После завершения установки перезагрузите компьютер. При следующем запуске вы сможете запускать команды прямо из Командная строка Windows.

Если вы ищете метод, который решит проблему без необходимости удаления клиента Git, перейдите к следующему способу ниже.

Способ 3: добавление переменной PATH вручную

Если вы зашли так далеко без результата, очень вероятно, что вы видите именно эту проблему, потому что переменная Git не сконфигурирована (или неправильно сконфигурирована) в Переменные среды.

К счастью, вы можете настроить значение переменной вручную, следуя набору инструкций. Вот что вам нужно сделать:

  1. Откройте проводник и перейдите к папке с cmd внутри установки Git. Вот пути по умолчанию для версий x86 и x64:
    Мой компьютер (Этот компьютер)> Локальный диск (C :)> Программные файлы (x86)> Git> cmd
    Мой компьютер (Этот компьютер)> Локальный диск (C :)> Программные файлы> Git> cmd
  2. Далее щелкните правой кнопкой мыши на git.exe и выбрать свойства. Затем в генеральный вкладка Свойства git.exe, скопируйте местоположение исполняемого файла (он понадобится нам позже).
    Скопируйте расположение git.exeСкопируйте расположение git.exe
  3. Далее нажмите Windows ключ + R открыть Бежать диалоговое окно, затем введите «sysdm.cplИ нажмите Войти открыть Свойства системы меню.
    Диалог запуска: sysdm.cplДиалог запуска: sysdm.cpl
  4. Внутри Свойства системы меню, перейдите к продвинутый вкладку и нажмите на Переменные среды.
    перейдите на вкладку «Дополнительно» и нажмите «Переменные среды»Перейдите на вкладку «Дополнительно» и нажмите «Переменные среды».
  5. Внутри Переменные среды меню, перейдите к Системные переменные в подменю выберите Дорожка, затем нажмите редактировать кнопка.
    Перейдите в Системные переменные, выберите Путь и нажмите кнопку Изменить.Перейдите в Системные переменные, выберите Путь и нажмите кнопку Изменить.
  6. в Изменить переменные среды нажмите кнопку новый нажмите кнопку и просто вставьте место, которое мы скопировали на шаге 2. Затем нажмите Войти создать переменную.
    Нажмите на Новый и вставьте git.exe's locationНажмите New и вставьте местоположение git.exe.
  7. Нажмите Хорошо в каждом открытом запросе, чтобы убедиться, что изменения сохранены.
  8. Откройте окно CMD и введите «git». Вы больше не должны сталкиваться с «Git’ не распознается как внутренняя или внешняя команда » ошибка.
    Git ошибка теперь устраненаОшибка терминала Git теперь устранена

Levman5

Привет, начал изучать git. Я установил его и в cmd.exe команда git —help работает, но в терминале vs code я получаю ошибку: «git» не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.

Как это исправить?


  • Вопрос задан

    более года назад

  • 2939 просмотров

Ctrl+Shift+P
потом «Terminal: Select Default Profile«
ну и там есть «Git Bash«
Это если нужна командная строка.
А ещё есть вкладка Source Control
619f3d78aac0a179777388.png
Изучайте :-)
Успехов!

Пригласить эксперта


  • Показать ещё
    Загружается…

04 февр. 2023, в 15:56

2500 руб./за проект

04 февр. 2023, в 15:46

200 руб./за проект

04 февр. 2023, в 15:45

200000 руб./за проект

Минуточку внимания

  • Remove From My Forums
  • Question

  • Hey there!

    I’m watching a course on PluralSight about the Azure Exam 70-533. In one of the video the tutor is using the command above, but he doesn’t say anything about that command, that’s an issue because this command won’t be implement by PowerShell. 

    I’ve already implemented this command:

    > Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
    > cd ~DocumentsWindowsPowerShellposh-git
    > .install.ps1

    That doesn’t fix the problem. Can you help me?

    Thanks in Advantage

Answers

  • You can use any Windows command in PowerShell.  The .Install.ps1 is a PS script used to install GIT after you have downloaded it.


    _(ツ)_/

    • Marked as answer by

      Thursday, October 12, 2017 7:37 AM

Понравилась статья? Поделить с друзьями:
  • Git for windows что это за программа
  • Git credential manager for windows что это
  • Gigabyte h510m h установка windows 7
  • Gnu gcc compiler для codeblocks скачать для windows
  • Git credential manager for windows как убрать