Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attach: introduce new built-in cmd
git-attach
The `git attach` built-in command is used to create, update, delete, view, download attachments related to a commit, etc. An attachment can be any regular file. The idea comes from that the emails contain metadata (subject, sender, recipient, body, etc.) and additional data (attachments), both of which have their own uses, and sometimes we can write one that contains both. Attachments are usually relatively larger. Users can whether or not to download and view attachments by their purpose. Just like the analogy to the email above, there are similar scenarios in git, some files we don't want to save directly to the commit itself. In addition, the mapping between the attachments and the commit is established by associating a git REF (inspired from `git notes`), so that the commit itself will not be overwritten if the attachements occur changes. For those who do not care about attachments, git generates behaves the same as before. Those who pay attention to the attachment can manage and maintain it by `git attach` subcommands or new options to existing commands in the future, for example $ git commit --attach foobar.bin Compared with using the attachment file directly as the BLOB object referenced by commits, you can clone or pull the code repository more quickly, whether you pay attention to the attachment or not. If you want to download/modify/add the attachment on a commit when you need, you can download the attachements at any time. This has broad significance in common scenarios, such as AI training codes with large models, tesing codes with test datasets, front-end codes with design materials, etc. Another solution we are familiar with is git lfs. By hooking and rewriting commit (using a pointer file to associate the lfs object), it can host the lfs object on an file storage service, thereby achieving excellent large file storage decoupling capabilities. Both git lfs and git attach can be used as solutions for large file storage, but there are 3 main differences between them: 1. The attachment object stored by git attach is still stored in the git repository, just another reference. If the user does not want to clone and fetch these attachments, they do not need to download these references, so the efficiency in pull speed is the same as git lfs is similar. 2. Another difference is that git lfs needs to be installed on the first step, while git attach is designed as one of the native git commands. It does not rely on external file storage services and uses the existing objects and reference mechanisms within git core. 3. Another is that git lfs is designed as a solution for storing large files. The effective file range is defined through git attributes, while git attach is designed to store any file, large or small, of any type. The concern is whether you want to store the files separately from the code, not just the file size. Signed-off-by: Teng Long <[email protected]>
- Loading branch information