Git-LFS large file storage

更新时间:
复制 MD 格式

This topic describes how to use Git large file storage (LFS) to manage large files in Alibaba Cloud DevOps Codeup, including aspects such as installation, configuration, and usage methods. The topic also provides practical tutorials for migrating existing repositories to the Codeup repositories.

Introduction to Git LFS

Background

  • Efficiency issues: Cloning or pulling operations in a Git repository with numerous large files can be time-consuming and bandwidth-intensive due to the download of all historical versions of these files.

  • Space issues: As a project grows, the associated Git repository can quickly increase in size, leading to performance degradation and higher maintenance costs.

What is Git LFS?

Git LFS is an open-source extension that enhances Git's handling of large files by allowing developers to track and download only the necessary versions of large files, thus reducing the local repository size and sync time. For more information, see What is Git LFS large file storage?.

Support for Git LFS in Codeup

Benefits

  • Stability: CodeUp provides high-availability storage services to ensure the security and reliability of Git LFS data.

  • Reliability: CodeUp automatically scales storage capacity and uses multiple redundant backups to protect data.

  • Capacity and cost efficiency: CodeUp provides a default Git LFS capacity of 5 GB per repository, which exceeds the industry average and helps lower costs.

  • Feature completeness: CodeUp provides complete support for Git LFS features, such as source code views, binary file downloads, image rendering, and diff comparisons.

Product capabilities

CodeUp provides support for the display of Git LFS text files, the download of binary files, and the rendering of image files. CodeUp also provides a detailed management interface for Git LFS to allow you to check upload records, download object files, and associate commit information. You can delete unnecessary LFS files directly to free up storage space.

For more information, see Introduction to Codeup Git LFS features.

How to use Git LFS

Installation and configuration

  • Download: Choose the appropriate installation package based on your operating system. On MacOS, simply install Git LFS by using Homebrew. On Windows, directly download the latest version of Git for Windows.

  • Install: After extraction, execute the installation script, it configures the environment variables and integrates Git LFS into your global Git settings.

  • Initialize the repository to support LFS: Run the git lfs install command to enable LFS functionality in the destination repository.

  • Track specific file patterns: Run the git lfs track "*.bigfile" command to specify the file types to be managed by LFS.

  • Commit your changes and push: Add, commit, and push files. Note that only the pointer files are uploaded to the Git server, while the actual large files are stored on the LFS server.

Clone a repository by using Git LFS

Ensure that Git LFS is correctly installed in your local environment. Otherwise, you clone LFS pointer files instead of the actual content. After you finish cloning, Git LFS automatically replaces the necessary hooks to enable LFS functionality.

For more information about the guide, see How to use Git LFS

Considerations when using Git LFS

FAQ and Solutions

  • Outdated version errors: Use the latest versions of Git and Git LFS to avoid compatibility issues and abnormal behavior.

  • Incomplete pulls due to missing Git LFS: If Git LFS is not installed, pulling a repository with LFS files will result in obtaining pointer files instead of the actual files. Make sure Git LFS is installed across all necessary environments.

  • Migrating large files in historical commits: Use the git lfs migrate command for existing repositories to shift large files in past commits to LFS. It's advisable to back up the repository before proceeding with a gradual migration to mitigate potential risks.

For more information, see Considerations when using Git LFS.

LFS migration guide

Scenarios

  • Enable LFS in a Codeup repository: Enable LFS functionality directly in the created Codeup repository.

  • Enable LFS and modify historical commits in a Codeup repository: Convert large files in the history of the existing repository to be managed by LFS.

  • Migrate a third-party repository to Codeup: Enable LFS for the first time and migrate existing LFS-configured third-party code repositories.

For more information about migration instructions, see LFS migration guide.

We hope that this topic provides you with a clearer understanding of how to apply Git LFS, especially involving team collaboration and large file management in Codeup. If you have inquiries or need any extra help, reach out to our technical support team.