Git uses a variety of different protocols depending on what your remote URL looks like.
If you're using an HTTP remote, it usually uses what's called the smart HTTP protocol, which is essentially an HTTP GET request of the remote references plus HTTP POST request to send the missing data. There is also a dumb HTTP protocol which uses WebDAV, but most hosting providers do not support it anymore.
If you're using an SSH remote, Git speaks the native Git protocol (which is also available over an unencrypted connection) to a Git program invoked on the remote side. The server does not use SFTP for this.
It used to be possible to use FTP for Git operations, but almost nobody does this anymore. This is because (a) FTP is hard to secure, since many implementations don't implement TLS behavior properly, (b) FTP is hard to use on a variety of networks because it requires opening multiple ports, (c) HTTP is generally faster than FTP, and (d) Git can send much, much less data by negotiating with the remote side over a connection instead just uploading files. For these first three reasons, FTP is uncommon in general and really should be considered obsolete.
SFTP is essentially speaking a specialized file transport protocol over an SSH connection. It is considered secure with a reasonable SSH connection, and is a good alternative to FTP. It is, in terms of messages sent, very different from FTP. Git does not use this natively, although it is possible to mount a remote directory using SFTP (e.g., with sshfs
) and then push into that repository as if it were a local repository. In this case, both sides of the Git protocol are actually operating on the local machine, and the files are being read and written to via SFTP.
You can find out more about the actual Git protocols here. Git does not use FTP or SFTP (which are two totally different things).
– Daniel B – 2020-02-29T00:12:53.097