Good day! Recently I began to use git and encountered the following problem, there are files on ftp, how can I transfer them to the github repository right away?

1 answer 1

Oddly enough, there are no files on the remote repository in GitHub. Instead, there is a content-addressable file system / database in which binary files are stored, from which you can unambiguously recover your files. These binary files are called blobs (BLOB - Binary Large OBject). As a zip-archive, only more complicated. In order not to work with all this manually, a version control system with higher-level functions was implemented on top.

Therefore, you cannot send files directly to the remote repository via the ftp protocol. You must first convert them to the desired format.

Your task is divided into several:

  1. Copy files from ftp to your local machine (I think, explanations are not needed). But if you have remote access to the server from FTP, you can work there as well.
  2. Add them and commit
  3. Send (push) to the githab.

I'll tell you about the process in more detail, so that it is clear why you cannot immediately FTP -> Git.

git status 

Git compares the structure and contents of 1) files in the workspace 2) file views in its own repository. For each discrepancy, it shows the result: the path and name of the file, the essence of the discrepancy (appeared, deleted, changed, not yet tracked). Convenient command, allowing you to navigate in what is happening - but to save files, it is optional.

 git add . 

Git reads the specified files, converts them into blobs organized into a tree (directed acyclic graph), and generates an index — a special list of files that will be included in the next commit. Binary files are stored together with others in a shared file system, but the index is separate from commits.

Instead of a dot there can be a path and / or file names

 git commit -m 'комментарий к коммиту' 

Git takes the index, adds the date, the name of the author, and some other data to it and forms the "commit" object from it. A commit also always has a link to the previous, "parent" commit (sometimes there are two or more). Now this commit becomes part of a common commit tree. It contains links to blobs that were previously in the index and in the previous commit, and the index is reset. The index of the current branch is moved to the newly created commit.

 git push 

Git establishes a connection with a remote server and "pushes" new changes to it. If the remote server already has a commit, then it will not be retransmitted. As we already know, each commit refers to a blob tree. When a commit is transmitted, all its contents are checked. If the remote server receives a new commit, but already has one of the blobs, then this blob will also not be transmitted.

  • Wrote a little hastily, there may be errors or inaccuracies. Criticism is welcome. ) - Nick Volynkin
  • In the github interface, there is an upload files button, with which local files can be “added as it were” to the repository. so the question (in this case) is reduced only to whether it is possible to mount the directory from the ftp server so that the files in it look local to the browser. in unix-like systems this can be done. in ms / windows - alas, I do not know. - aleksandr barakin
  • @alexanderbarakin Well, I feel like a old fart. I do not know about the new fashionable hipster features. ) - Nick Volynkin
  • Yes, I myself learned about it 8 hours ago (see my comment in question). therefore did not begin to write the answer. (I would call this “feature” not “hipster”, but “homemade”). - aleksandr barakin
  • @alexanderbarakin ftpdrive to help. Well, ntfs-links (mklink / D) Addit them to the local repository, but give a commit. It should work. - Evgeny Borisov