Does `git push` use ftp/sftp to send data to Github/Bitbucket?

1

I am trying to understand more about the internals FTP/SFTP and the underlying technologies (complete noob alert!) Like many developers I use Git and Github in my workflow, and while learning about ftp, I wondered what protocol git used to send my source code files to Github (or any code hosting webservice)

Browsing through the man-page of git-push didn't seem to offer any information on what the underlying technology being used for the file-transfers are. I assume they have probably abstracted this away, so that some other file transfer can be used, but I would like to know what is the default used by Git Push for sending data over to Github or bitbucket.

smilingbuddha

Posted 2020-02-28T23:32:10.427

Reputation: 1 591

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

Answers

1

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.

bk2204

Posted 2020-02-28T23:32:10.427

Reputation: 261