git-receive-pack/git-upload-pack 和 git-http-backend 之间的区别

Differences between git-receive-pack/git-upload-pack and git-http-backend

为了进一步了解 git,我尝试使用 Python 和 Flask 编写一个非常简单的 Git 服务器。我注册了一个端点并将调用重定向到 git-http-backend。到目前为止,简单的拉动效果很好。 simple/small 推送也通过了。

现在我无意中发现 git-upload-pack and git-receive-pack,我想知道为什么或何时需要它们? git-http-backend 在后台使用它们吗?我不确定我是否还必须支持这些命令。

P.S。我试着全神贯注于 SmartHTTP。是全双工的意思吗?或者什么是 SmartHTTP vs Dumb?我不完全明白如果它也只是接收和 sends/pushes 一个文件应该是什么智能?

我提交了 in 2011 with Git 1.6.6.

但是 git-receive-pack and git-upload-pack 即使没有 HTTP 也会涉及,例如 SSH URL.

我必须了解它们,因为我经常在我不是 root 的服务器上安装 Git。
这意味着可执行文件 git 不在 /usr/bin 中,而是在 /my/path/to/git/usr/bin

每当我从该服务器(或 git ls-remote)在我的 PC 上执行 git clone 时,我得到:

bash: git-upload-pack: command not found

如果我尝试 git push 从我的 PC 到该服务器:

bash: git-receive-pack: command not found

那是因为,当您查看 Git 安装的 usr/bin 文件夹时,您会看到:

-rwxr-xr-x. 1 <auser> <agroup> 3.0M Dec 13  2019 git*
drwxr-xr-x. 5 <auser> <agroup>   45 Jun  8 14:35 ../
drwxr-xr-x. 2 <auser> <agroup>  107 Jun  8 14:35 ./
lrwxrwxrwx. 1 <auser> <agroup>    3 Jun  8 14:35 git-receive-pack -> git*
lrwxrwxrwx. 1 <auser> <agroup>    3 Jun  8 14:35 git-upload-pack -> git*
lrwxrwxrwx. 1 <auser> <agroup>    3 Jun  8 14:35 git-upload-archive -> git*

意思是 git-receive-pack and git-upload-pack 只是 git 本身的符号链接 (!)

但是,由于它们的命名约定 (git-xxx),它们实际上是使用命令 receive-packupload-pack.
调用 git (顺便说一下,这适用于 $PATH 中的任何脚本 git-xxx:然后您可以键入 git xxx,这将调用您的 git-xxx 脚本)

为了使我的自定义 Git 安装正常工作,我必须实施 git-xxx 包装器:

示例:

/my/path/to/git/git-receive-pack:

#!/bin/bash

source "setenv"
"/my/path/to/git/usr/bin/git" receive-pack "$@"

使用 setenv 设置正确的路径:

export PERLLIB=/my/path/to/git/usr/share/perl5/vendor_perl:/my/path/to/git/opt/endpoint/perl-5.22.0/share/perl5/vendor_perl
export PATH=/my/path/to/git/usr/bin:/my/path/to/git/usr/libexec/git-core:$PATH
export LD_LIBRARY_PATH=/project/${USER}/refer/pcres/current/usr/lib64

并且在客户端 (PC) 端,对于使用具有自定义 Git 安装的服务器的远程,我需要添加:

git config --global remote.origin.uploadpack /my/path/to/git/git-upload-pack
git config --global remote.origin.receivepack=/my/path/to/git/git-receive-pack