Git and libgit2

Git LFS Scripts

Published 2025-01-24.
Time to read: 3 minutes.

This page is part of the git collection.

I have published 8 articles about the Git large file system (LFS). They are meant to be read in order.

  1. Git Large File System Overview
  2. Git LFS Scripts
  3. Git LFS Client Installation
  4. Git LFS Server URLs
  5. Git-ls-files, Wildmatch Patterns and Permutation Scripts
  6. Git LFS Tracking, Migration and Un-Migration
  7. Git LFS Client Configuration & Commands
  8. Git LFS SSH Authentication
  9. Working With Git LFS
  10. Evaluation Procedure For Git LFS Servers
  11. Git LFS server tests:
    1. Null Git LFS Server

6 articles are still in process.

Instructions for typing along are given for Ubuntu and WSL/Ubuntu. If you have a Mac, most of this information should be helpful.

These Scripts Probably Contain Errors

These scripts are incomplete and may contain errors. They have been published to allow collaboration with fact-checkers. Do not rely on this information yet.

The scripts included in the git_lfs_scripts GitHub repository are useful for testing and operating Git LFS.

This article lists each script and provides a link to the article that fully describes and uses the scripts.

The scripts were written for native Ubuntu and Ubuntu under WSL. Although many of them will probably work on macOS, I have not tested macOS compatibility.

Scripts for Testing Git LFS Implementations

These scripts were expressly written for this miniseries on Git LFS. They are designed to work together when testing Git LFS implementations.

Scripts for Working With Git LFS

These scripts are generally useful when working with Git LFS.

  • git-lfs-trace.html is not a public page yet: A Git client extension that reports activity between the Git client and the Gif LFS server.
  • giftless.html is not a public page yet: Runs the giftless Git LFS server.
  • lfs-files: Front-end script for git lfs ls-files that handles wildmatch patterns, with special consideration for media files.
  • ls-files: Front-end script for git ls-files that handles wildmatch patterns, with special consideration for media files.
  • new_bare_repo: Creates a bare Git repository with the SGID permission set.
  • nonlfs: Lists files that are not managed by Git LFS in the current repository.
  • track: Front-end script for git lfs track that handles wildmatch patterns, with special consideration for media files.
  • unmigrate: Moves files migrated to Git LFS by the git lfs migrate import command; it includes special consideration for the wildmatch patterns of media files.
  • untrack: Front-end script for git lfs untrack that handles wildmatch patterns, with special consideration for media files.

Installation

The scripts are stored in the GitHub repository with the executable bits set. When you clone the repository those executable bits will remain set.

All you have to do is add the bin/ directory of the repository to the PATH. This will make all of the scripts available.

The following is an example of how to do that; it assumes that the path you clone the GitHub repository to does not have spaces:

Shell
$ git clone https://github.com/mslinn/git_lfs_scripts.git
Cloning into 'git_lfs_scripts'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 19 (delta 2), reused 19 (delta 2), pack-reused 0 (from 0)
Receiving objects: 100% (19/19), 10.77 KiB | 648.00 KiB/s, done.
Resolving deltas: 100% (2/2), done. 
$ echo "$(pwd)/git_lfs_scripts/bin:\$PATH" >> ~/.bashrc
$ source ~/.bashrc
$ sudo ln -s "$( which ls-files )" /usr/local/bin/lfs-files
$ sudo ln -s "$( which ls-files )" /usr/local/bin/track
$ sudo ln -s "$( which ls-files )" /usr/local/bin/untrack

About the Prompts

Throughout this series of articles, command-line sequences showing at least two computers are often displayed. For example, the following was typed on my desktop computer called bear from a directory called /ab/cd/ef/:

Bear
mslinn@bear ef $ pwd
/ab/cd/ef 

The bash prompt highlighted above presented a lot of information. So that readers can easily keep track of what is happening where, the following was the definition for the bash prompt:

~/.bashrc fragment
export PS1='\u@\h \W \$ '

Defining PS1 in this way displays the following:

  1. User ID of the person logged in to the terminal session (I am mslinn everywhere).
  2. @ delimiter.
  3. Network node name, which is often equivalent to the name of the computer. Pay attention to that portion of the prompt because that will tell you the name of the computer on which the command was executed. I mostly used bear, my desktop computer running Windows 10 and WSL2, and gojira, my Ubuntu server.
  4. Space character
  5. Current directory name. For example, if the full path of the current directory is /ab/cd/ef/, then only ef would be displayed.
  6. Space character.
  7. $ dollar sign.
  8. Space character.

I have published 8 articles about the Git large file system (LFS). They are meant to be read in order.

  1. Git Large File System Overview
  2. Git LFS Scripts
  3. Git LFS Client Installation
  4. Git LFS Server URLs
  5. Git-ls-files, Wildmatch Patterns and Permutation Scripts
  6. Git LFS Tracking, Migration and Un-Migration
  7. Git LFS Client Configuration & Commands
  8. Git LFS SSH Authentication
  9. Working With Git LFS
  10. Evaluation Procedure For Git LFS Servers
  11. Git LFS server tests:
    1. Null Git LFS Server

6 articles are still in process.

Instructions for typing along are given for Ubuntu and WSL/Ubuntu. If you have a Mac, most of this information should be helpful.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.