Set up LFS client and work with large files

Download the Git LFS client for your platform. Instructions in this topic are valid for Git LFS client 1.3 and later. Once you have the LFS set up, you can use extended checkout URL, select the file types you'd like Git LFS to manage, create a commit by adding binary file and technical file (.gitattributes) and finally push the files to remote repositories.

For downloading Git LFS client, see Git Large File Storage page.

Working with LFS over HTTP/HTTPS (without replication)

  1. Use extended checkout URL.

    Example:

    git clone http://product_developer@ctf-centos72-dev-box.collab.net/gerrit/test_repo && cd
          "test_repo" && git config user.name "Nancy S." && git config user.email
          "nancy@example.com" && curl -o .git/hooks/commit-msg
          http://product_developer@ctf-centos72-dev-box.collab.net/gerrit/tools/hooks/commit-msg &&
          chmod +x .git/hooks/commit-msg
  2. Select the file types you'd like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions anytime.

    The following command tracks all .jpg images in a given working directory.

    • git lfs track *.jpg
  3. Create a commit by adding the binary file and the technical file (.gitattributes) that is modified by Git LFS client.
    • git add IMG_0036.jpg .gitattributes
  4. Commit and push the file(s) to the remote repository.
    • git commit -sm 'This is LFS test' && git push origin HEAD:master
    The binary file that is successfully pushed to LFS manifests itself by having a reference file committed to Gerrit and you can check its content by going to TeamForge code browser for the given repository. Here is an example reference file. It contains Git LFS protocol version specification along with Git LFS object SHA and its size.

Working with LFS over SSH

  1. LFS doesn’t work over SSH and is supported over HTTP/HTTPS connection to Gerrit server. Therefore, you must modify the extended checkout URL (in red below).
    git clone  -c 'lfs.url=http://product_developer@ctf-centos72-dev-box.collab.net/gerrit/test_repo.git/info/lfs' 
            ssh://product_developer@ctf-centos72-dev-box.collab.net:29418/test_repo && cd "test_repo"
            && git config user.name "Nancy S." && git config user.email "nancy@example.com" && scp
            -P 29418 product_developer@ctf-centos72-dev-box.collab.net:hooks/commit-msg
            .git/hooks/

Working with LFS (with replication)

  1. LFS is not replicated and is always served from main server. Therefore, your checkout URLs must be modified accordingly (in red below).
    HTTP/HTTPS
    git clone -c 'lfs.url=http://product_developer@ctf-centos72-dev-box.collab.net/gerrit/test_repo.git/info/lfs'
          http://product_developer@ctf-centos72-replica.collab.net/gerrit/test_repo && cd "test_repo"
          && git config user.name "Nancy S." && git config user.email "nancy@example.com" && git
          config url."http://ctf-centos72-replica.collab.net/gerrit".insteadOf
          "http://ctf-centos72-dev-box.collab.net/gerrit" && git config
          url."http://product_developer@ctf-centos72-replica.collab.net/gerrit".insteadOf
          "http://product_developer@ctf-centos72-dev-box.collab.net/gerrit" && git config
          url."http://product_developer@ctf-centos72-dev-box.collab.net/gerrit".pushInsteadOf
          "http://product_developer@ctf-centos72-replica.collab.net/gerrit" && curl -o
          .git/hooks/commit-msg
          http://product_developer@ctf-centos72-replica.collab.net/gerrit/tools/hooks/commit-msg &&
          chmod +x .git/hooks/commit-msg
    SSH
    git clone -c 'lfs.url=http://product_developer@ctf-centos72-dev-box.collab.net/gerrit/test_repo.git/info/lfs'
          ssh://product_developer@ctf-centos72-replica.collab.net:29418/test_repo && cd "test_repo" &&
          git config user.name "Nancy S." && git config user.email "nancy@example.com" && git config
          url."ssh://ctf-centos72-replica.collab.net:29418".insteadOf
          "ssh://ctf-centos72-dev-box.collab.net:29418" && git config
          url."ssh://product_developer@ctf-centos72-replica.collab.net:29418".insteadOf
          "ssh://product_developer@ctf-centos72-dev-box.collab.net:29418" && git config
          url."ssh://product_developer@ctf-centos72-dev-box.collab.net:29418".pushInsteadOf
          "ssh://product_developer@ctf-centos72-replica.collab.net:29418" && scp -P 29418  product_developer@ctf-centos72-replica.collab.net:hooks/commit-msg