Skip to content
rindeal edited this page Sep 18, 2024 · 11 revisions

Welcome to the git-remote-refs-cmp wiki!

https://git-scm.com/docs/gitprotocol-v2#_ls_refs

examples of unusual ls-remote reponses:

2d563a054497c2adade24c42b3c8188035b8393e HEAD symref-target:refs/heads/master
2d563a054497c2adade24c42b3c8188035b8393e refs/heads/foo symref-target:refs/heads/bar peeled:2d563a054497c2adade24c42b3c8188035b8393e
unborn refs/heads/name

git debugging/tracing

export GIT_TRACE=1                                                                                                
export GIT_TRACE_PACK_ACCESS=1
export GIT_TRACE_PACKET=1
export GIT_TRACE_PERFORMANCE=1
export GIT_TRACE_SETUP=1

simulate .../info/refs?service=git-upload-pack GET request response

GIT_PROTOCOL=version=2 git upload-pack --http-backend-info-refs /tmp/foo-git
#!/bin/bash

export GIT_TRACE=1
export GIT_TRACE_PACK_ACCESS=1
export GIT_TRACE_PACKET=1
export GIT_TRACE_PERFORMANCE=1
export GIT_TRACE_SETUP=1


export HTTP_GIT_PROTOCOL="version=2"  # `Git-Protocol:` header
export GIT_PROJECT_ROOT='/tmp/foo-git'
export GIT_HTTP_EXPORT_ALL=1
export REQUEST_METHOD='GET'
export QUERY_STRING="service=git-upload-pack"
export PATH_INFO="/info/refs"
export CONTENT_TYPE="application/x-git-upload-pack-request"


# Simulate the HTTP request
/usr/libexec/git-core/git-http-backend

sample stdout output:

Headers:
Expires: Fri, 01 Jan 1980 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate
Content-Type: application/x-git-upload-pack-advertisement
Data:
000eversion 2
0015agent=git/2.46.0
0013ls-refs=unborn
0020fetch=shallow wait-for-done
0012server-option
0017object-format=sha1
0000% 

Simulate git ls-remote command:

{
    # echo "capabilities"
    # sleep 0.01
    # echo 'option verbosity 1'
    echo 'stateless-connect git-upload-pack'
    sleep 0.01
    printf '0014command=ls-refs\n0017object-format=sha1\n00010009peel\n000csymrefs\n000bunborn\n0000'
} | GIT_CURL_VERBOSE=1 /usr/libexec/git-core/git-remote-https https://github.com/git/git
Clone this wiki locally