Enable and Use Git LFS to Version Large Files

If your projects contain large files, especially files that are modified often, an initial clone can take a long time because your Git client needs to download every version of every file. Git LFS (Large File Storage) minimizes the time needed for downloading large files in your repository by downloading the relevant versions during the checkout process instead of during clone or fetch operations. Git LFS does this by replacing large files in your repository with small pointer files that you'll probably never even see. Git LFS automatically handles the replacements and stores the large file contents in an OCI Storage Bucket.

By default, VB Studio enables Git LFS in all Git repositories for the entire organization.

If you need to store large or binary files in your project, here's how you enable and use Git LFS for a repository in the project:

  1. Verify that your VB Studio instance is authorized to access OCI Object Storage, which is typically part of the VB Studio instance set up. This is important because Git LFS needs an OCI storage bucket to hold large files. Here's how to check this:
    1. Log in to your VB Studio instance.
    2. In the left navigator, click Organization and then click OCI Account
    3. Look for this message: VBS instance configured in OCI console.

      If the message appears, your instance has access to OCI Object Storage. You can go to the next step.

      If the message doesn't appear, it means your instance doesn't have access to OCI Object Storage. Before proceeding, you or an Administrator will need to enable this for your VB Studio instance.

  2. Clone the project's Git repository.

    You can find the URL for the remote repository from the Project Home page's Repositories tab. From the Clone drop-down list, click Copy to clipboard the Copy icon to copy the URL, then paste it to the command line:

    git clone <SSH/HTTPS repository URL>

    You must be connected to the Internet and to the remote repository to check out a branch locally.

  3. Enable Git LFS for the local Git repository:

    git lfs install

    This is required because the + File button on the Git page can't be used to upload or add a binary file directly in a remote Git repository. The only way to add a binary file is through a cloned repository.

  4. Specify the file(s) to track. For example, to track all Microsoft Excel files:

    git lsf track "*.xslx"

  5. Stage the files to be committed:

    git add .

    git add .gitattributes

  6. Commit the files to the local repository:

    git commit -a -m "Initial commit using LFS"

  7. Push the commits to the remote repository:

    git push origin main

    Now when a binary file is pushed to a remote Git repository, it's stored on the VB Studio-connected OCI Object Storage bucket. A reference is added to the Git repository, not to the file.

    If a connection to the OCI Object Storage bucket can't be made, you'll see an error message that indicates storage hasn't been enabled.

    When a Git repository that uses Git LFS is deleted, its binary files on OCI Object Storage are also deleted.