错误:找不到 git - 使用 Composer windows 安装 laravel

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20169348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:23:38  来源:igfitidea点击:

error: git was not found - installing laravel with composer windows

phpgitlaravel-4composer-php

提问by a7omiton

I'm getting an error saying:

我收到一条错误消息:

failed to clone https://github.com/php-fig/log.git, git was not found, check that it is installed and in your PATH env.

'git' is not recognized as and internal or external command, operable program or batch file

when I try and run composer create-project laravel/laravel learning-laravel.

当我尝试运行时composer create-project laravel/laravel learning-laravel

I installed the git GUI which also comes with a command line shell, but I don't know why its not recognising the command (I'm issuing the create-project command in the normal windows command line prompt).

我安装了 git GUI,它也带有命令行 shell,但我不知道为什么它不能识别命令(我在普通的 Windows 命令行提示符下发出 create-project 命令)。

I also tried running the command from the git shell, which worked, but when I tried php artisan serveit gave me an error saying CLI has stopped working.

我还尝试从 git shell 运行命令,该命令有效,但是当我尝试时,php artisan serve它给了我一个错误,提示 CLI 已停止工作。

Does anyone know how to fix the git error? I'd rather use the windows command shell instead of the git one as it can then go into my wamp/www file

有谁知道如何修复 git 错误?我宁愿使用 windows 命令外壳而不是 git 一个,因为它可以进入我的 wamp/www 文件

回答by Jeroen

You need to add the directory you installed git to to your PATH environment variable.

您需要将安装 git 的目录添加到 PATH 环境变量中。

  1. Right click on Computer.
  2. Click Advanced System Settings
  3. Click Environment Variables inside the Advanced Menu
  4. Under System Variables, scroll to PATH
  5. Add ;"C:\path\to\git\bin";"C:\path\to\git\cmd"
  1. 右键单击Computer
  2. 单击高级系统设置
  3. 单击高级菜单中的环境变量
  4. 在系统变量下,滚动到 PATH
  5. 添加 ;"C:\path\to\git\bin";"C:\path\to\git\cmd"

Test the git command in the command prompt to see if it worked. Git is usually located in Program Filesor Program Files(x86).

在命令提示符下测试 git 命令,看看它是否有效。Git 通常位于Program Files或 中Program Files(x86)

回答by Allfarid Morales García

There is an easier (but temporal) way to add a path variable in Windows.

有一种更简单(但临时)的方法可以在 Windows 中添加路径变量。

Paste this in your command prompt:

将此粘贴到您的命令提示符中:

SET PATH=%PATH%;C:\Program Files\Git\bin

This will work for the rest of the command prompt session. Don't forget installing Git before this.

这将适用于命令提示符会话的其余部分。在此之前不要忘记安装 Git。

回答by SomeKittens

You'll need to add git to your system PATH if you want to use it in regular command prompt.

如果您想在常规命令提示符下使用它,则需要将 git 添加到您的系统 PATH 中。

Here's a guide on modifying your system path in Windows:

这是在 Windows 中修改系统路径的指南:

http://www.computerhope.com/issues/ch000549.htm

http://www.computerhope.com/issues/ch000549.htm

回答by kkemple

you need to uninstall git and reinstall ( or update ) in the options you need to change from git bash only to allow git to be added to command line as well, also since it then adds it to your path you may or may not need to restart your computer

您需要卸载 git 并重新安装(或更新)您需要从 git bash 更改的选项中仅允许将 git 添加到命令行,而且因为它随后将其添加到您的路径中,您可能需要也可能不需要重启你的电脑

回答by hmoyat

I was having some issues using git on Windows. I found this information only and it worked for me.

我在 Windows 上使用 git 时遇到了一些问题。我只找到了这个信息,它对我有用。

http://ccn.ucla.edu/wiki/index.php/Setting_Up_and_Using_Git#Windows

http://ccn.ucla.edu/wiki/index.php/Setting_Up_and_Using_Git#Windows