Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Transfer Protocol Specifications

Tags:

git

I'm playing around with git's transfer protocols, and I was just wondering if there is some detailed specification for them before I attempt to read the source?

like image 305
Emil Davtyan Avatar asked Sep 14 '13 05:09

Emil Davtyan


People also ask

What protocol does Git use to transfer files?

Git can transfer data between two repositories in two major ways: the “dumb” protocol and the “smart” protocol. This section will quickly cover how these two main protocols operate.

Does Git use TCP?

In Git, locations in the form of [user@]server:path are interpreted as SSH addresses (and the 'clone' tool literally runs ssh [user@]server in the background). By default, SSH connects to port 22/tcp, which is the standard SSH port.

What is your preferred protocol for Git operations?

The default on both GitHub.com (the website) and in GitHub CLI is using the HTTPS protocol for git operations. This default was chosen for interoperability and ease of use: Git users who are behind firewalls find that traffic to port 443 (HTTPS) is more often allowed than traffic to port 22 (SSH).


2 Answers

Update May 2018: Starting Q2 2018 and Git 2.18, you will have the Git transfer protocol v2: See "How does Git's transfer protocol work".


Original answer 2013:

First, check the git documentation in the git repo itself (with a good grep, available even on Windows):

git clone https://github.com/git/git
cd git/Documentation
grep -nRHI "receive-pack" *

That will give you pointers to:

  • http-protocol But also:
  • pack-heuristics
  • pack-protocol
  • protocol capabilities
  • send-pack pipeline

Then you can complete that set of documentation with ones related to the backend commands:

  • git-http-backend
  • git-receive-pack
  • git-remote-ext
  • git-send-pack
  • gitremote-helpers

One way at looking at the source is by looking at the recent evolutions around transfer and transport in the git repo:

git clone https://github.com/git/git
cd git
git log -Stransfer

Have a look at:

  • commit 4bc444 (Support FTP-over-SSL/TLS for regular FTP)
  • commit daebaa (upload/receive-pack: allow hiding ref hierarchies )
  • commit 745f7a (fetch-pack: move core code to libgit.a)
  • commit fe0435 (Add persistent-https to contrib)
  • ...

Another way is to have a look at other implementation of git:

  • Java: jgit, and its Transport.java source (tested in TransportTest.java, which declines into:
    • TCpTransport
    • TransportHttp
    • TransportSftp
    • TransportLocal
    • TransportBundle

 

  • C, with libgit2, and its src/transports sources.

  • ... and so on

like image 133
VonC Avatar answered Nov 07 '22 00:11

VonC


there is also a partially completed documentation hosted on Github Gist.

This metasploit module also poses as a malicious dumb git server, serving bad git trees. You can see how the git trees are constructed.

like image 28
vincentleest Avatar answered Nov 07 '22 01:11

vincentleest