Git's Transport Protocols

The URL decides how Git 1,932 reaches a remote. An OpenSSH 23,707 server on port 32022 of this machine accepts Sam's key, so the bare repository answers over SSH too, and a packet trace shows the wire protocol:

The same repository over SSH, and the protocol version on the wireShell
git ls-remote ssh://dev@localhost:32022/home/dev/v5-ch2/server/booknest.git
GIT_TRACE_PACKET=1 git ls-remote origin 2>&1 | sed 's/.*packet: *//' | grep -E 'version|command='
Output
a2508dab6ff752b05655d0c7ff254b7e2d4703cf        HEAD
471ce3b6cedd03752a8ebe4275a0647d7be1a3b3        refs/heads/dev-docs
a2508dab6ff752b05655d0c7ff254b7e2d4703cf        refs/heads/main
upload-pack> version 2
ls-remote< version 2
ls-remote> command=ls-refs
upload-pack< command=ls-refs

Every transport runs one conversation: the client starts git-upload-pack (fetch) or git-receive-pack (push) on the other side, over a pipe, SSH or HTTP. Protocol version 2, the default since Git 2.29 (2020), lets the client request only the refs it wants (ls-refs) instead of receiving the whole list.

Git's transports
Transport URL form Authentication Typical use
Local /srv/git/app.git, file:///srv/git/app.git File permissions Shared disks, tests
SSH ssh://user@host:port/path, user@host:path SSH keys Teams, private servers
Smart HTTPS https://host/path.git Tokens, credential helper Hosting services
Git protocol git://host/path.git None, read-only Rare public mirrors

The scp-like user@host:path cannot carry a port; use the ssh:// form for that. Plain paths copy objects directly, while file:// runs the real protocol (Shallow Clones). HTTPS passes firewalls and uses the credential helpers of Credential Helpers.