2022-08-18 00:25:38 +00:00
|
|
|
---
|
2022-11-12 18:14:33 +00:00
|
|
|
title: "git-lfs"
|
2025-02-12 16:46:59 +00:00
|
|
|
tags: [ "data", "git" ]
|
2022-08-18 00:25:38 +00:00
|
|
|
---
|
|
|
|
|
2025-02-12 16:46:59 +00:00
|
|
|
Git Large File Storage ('LFS') needs to change your `~/.gitconfig` to check out those binary files:
|
2022-08-18 00:25:38 +00:00
|
|
|
|
2025-02-12 16:46:59 +00:00
|
|
|
```sh
|
|
|
|
cat ~/.gitconfig
|
2023-06-17 19:28:20 +00:00
|
|
|
git lfs install
|
2025-02-12 16:46:59 +00:00
|
|
|
cat ~/.gitconfig
|
2023-06-17 19:28:20 +00:00
|
|
|
```
|
2022-08-18 00:25:38 +00:00
|
|
|
|
2025-02-12 16:46:59 +00:00
|
|
|
Then track some filetypes with:
|
2022-08-18 00:25:38 +00:00
|
|
|
|
2025-02-12 16:46:59 +00:00
|
|
|
```sh
|
|
|
|
cd $git_repository
|
|
|
|
ext=ttf
|
|
|
|
git lfs track "*.$ext"
|
2023-06-17 19:28:20 +00:00
|
|
|
```
|
2022-08-18 00:25:38 +00:00
|
|
|
|
|
|
|
Or a directory with:
|
|
|
|
|
2025-02-12 16:46:59 +00:00
|
|
|
```sh
|
2023-06-17 19:28:20 +00:00
|
|
|
git lfs track "images/"
|
|
|
|
```
|
2022-08-18 00:25:38 +00:00
|
|
|
|
2025-02-12 16:46:59 +00:00
|
|
|
Track the changes to `.gitattributes`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git status
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "add $ext to lfs"
|
|
|
|
```
|
|
|
|
|
|
|
|
## Bash Completion
|
|
|
|
|
|
|
|
If bash completion does not work, you'll have to add it:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git lfs completion bash | sudo tee /usr/share/bash-completion/completions/git-lfs
|
|
|
|
```
|
|
|
|
|
|
|
|
## Trouble Shooting
|
|
|
|
|
|
|
|
You have some file "$FILE".png, which has some problem.
|
|
|
|
|
|
|
|
Check the filetype:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
file "$FILE".png
|
|
|
|
```
|
|
|
|
|
|
|
|
This should say the type is 'image'.
|
|
|
|
If it says the type is 'text', then this file is really just a reminder to `git-lfs` to check out that file.
|
|
|
|
|
|
|
|
Check `git-lfs` is expecting that file:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git lfs status
|
|
|
|
git lfs ls-files
|
|
|
|
```
|
|
|
|
|
|
|
|
...then try these commands, and check the filetype again:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git lfs fetch --all
|
|
|
|
git lfs fsck
|
|
|
|
git lfs checkout
|
|
|
|
git lfs status
|
|
|
|
```
|
|
|
|
|