git-receive-pack:在 Windows 中找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1483722/
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 03:51:45  来源:igfitidea点击:

git-receive-pack: command not found in Windows

git

提问by

Wondering how to fix this problem in Windows ?

想知道如何在 Windows 中解决这个问题?

When i try and use the command "git push origin master" I get

当我尝试使用命令“git push origin master”时,我得到

git-receive-pack: command not found

git-receive-pack:找不到命令

Any idea how I can fix this in windows ?

知道如何在 Windows 中解决此问题吗?

The path to GIT is in c:/program files/Git/Bin/ but unsure how to set this ?

GIT 的路径在 c:/program files/Git/Bin/ 中,但不确定如何设置?

Thx

谢谢

Edit:doing

编辑:

git--exec-path
c:\Program Files\Git/libexec/git-core

git--exec-path
c:\Program Files\Git/libexec/git-core

Now how to setup this somewhere?

现在如何在某处设置它?

回答by VonC

From Git FAQ:

Basically the problem is that 'git-receive-pack' is not in the default $PATH on the remote end.

来自Git 常见问题解答

基本上问题在于“git-receive-pack”不在远程端的默认 $PATH 中。

You can see the problem using a DOS window:

您可以使用 DOS 窗口查看问题:

set PATH

(display the path)

(显示路径)

type

类型

set PATH=%PATH%;"c:/program files/Git/Bin"
git push origin master

If that solves the problem, you will be better off adding that path in your user environment variables (see this superuser questionfor instance)

如果这解决了问题,您最好在用户环境变量中添加该路径(例如,请参阅此超级用户问题



Or a bash Git shell:

或者一个 bash Git shell:

$ export PATH=$PATH:"/c/Program Files/Git/bin"
$ git push origin master

Check also your .bashrcin your $HOME path ('echo $HOME' within a bash session; add the export line in it, or simply '~/.bashrc')

还要检查您.bashrc的 $HOME 路径(echo $HOMEbash 会话中的“ ”;在其中添加导出行,或者只是“ ~/.bashrc”)



Note: a classic msysgit installation should have taken care of those path.

注意:经典的 msysgit 安装应该已经处理了这些路径。

回答by DTS

I had a similar problem when trying to execute a git pull from another Win-7 machine. Here's what I did:

我在尝试从另一台 Win-7 机器执行 git pull 时遇到了类似的问题。这是我所做的:

  • In order to interact with remote repositories via Git, the Git directories need to be added to the REMOTE machine's Windows PATH environmental variable (this should be done for any Windows machine running Git and needing to clone, push, or pull)
  • Git directories to add (so far):

    ..\git\bin, ..\git\libexec\git-core, ..\git\cmd

  • To modify the Windows-7 path, use the following:

    Click Start, then right-click on "Computer" and select "Properties", On the left panel, select "Advanced system settings", In the System Properties dialog, click on the "Environmental Variables…" button, Select "Path" from the "System variables list", and click the "Edit" button

  • 为了通过 Git 与远程存储库进行交互,需要将 Git 目录添加到远程机器的 Windows PATH 环境变量中(这应该针对任何运行 Git 并需要克隆、推送或拉取的 Windows 机器完成)
  • 要添加的 Git 目录(到目前为止):

    ..\git\bin、..\git\libexec\git-core、..\git\cmd

  • 要修改 Windows-7 路径,请使用以下命令:

    单击开始,然后右键单击“计算机”并选择“属性”,在左侧面板上选择“高级系统设置”,在“系统属性”对话框中,单击“环境变量...”按钮,选择“路径” “系统变量列表”,然后单击“编辑”按钮

Add the needed paths to the end of the existing Path string using a semi-colon as the delimiter. Note: the path needs to be specified from the disk root (e.g. C:).

使用分号作为分隔符将所需的路径添加到现有路径字符串的末尾。注意:路径需要从磁盘根目录(例如 C:)指定。

回答by johnsabre

You need to add the bin folder path where git was installed to the PATHS of the Windows System Environment variables. But if you have installed git using a 64-bit installer the path is different:

需要将安装git的bin文件夹路径添加到Windows系统环境变量的PATHS中。但是,如果您使用 64 位安装程序安装了 git,则路径不同:

C:\Program Files\Git\mingw64\bin

notice the sub path "mingw64".

注意子路径“mingw64”。

回答by Kyle Carlson

I had this problem when I mistakenly tried to git clonea repo that was actually a Mercurialrepo. Someone else created the project and I'd never used Mercurial before.

当我错误地尝试git clone一个实际上是一个Mercurialrepo的 repo 时,我遇到了这个问题。该项目是由其他人创建的,而我之前从未使用过 Mercurial。

Felt like an idiot, but I couldn't find any answers on SO that fixed it. Whoops!

感觉像个白痴,但我找不到解决它的任何答案。哎呀!