Gangmax Blog

git lfs

From here.

1
2
3
4
5
6
7
8
9
10
11
# The issue happens when a file is too big to save into git repo.
git push origin main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 653.14 KiB | 358.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: warning: See https://gh.io/lfs for more information.
remote: warning: File cache.db is 69.36 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
1
2
3
4
5
6
7
8
9
10
# 1. Install "git-lfs".
sudo apt-get install git-lfs
# 2. Setup "git-lfs".
git lfs install
git lfs track "cache.db"
git add .gitattributes
# 3. Do git operations as usual.
git add .
git commit -m 'Add the latest content.'
git push origin main

The core Git LFS idea is that instead of writing large blobs to a Git repository, only a pointer file is written. More details can be found in the offline document.


Added on 2024-06-05.

1
2
3
4
5
6
7
8
# Retrieve original files after a git clone with git lfs. From:
# https://stackoverflow.com/a/72830455/3115617

# Fetch all the LFS files from the remote.
git lfs fetch

# Replace the pointer files to the actual files.
git lfs checkout

Comments