C.W.K.
Stream
Lesson 04 of 04 · published

Sparse, partial, shallow, LFS

~22 min · large-repos, sparse-checkout, lfs

Level 0Untracked 새싹
0 XP0/47 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Sparse, partial, shallow, LFS — 큰 거 다루는 네 방법

Linux 커널 repo 는 5 GB. Chromium repo 는 30+ GB. 게임 asset repo 는 수백 GB 가능. 일반 노트북에서 plain git clone 은 고통스럽거나 불가능. Git 은 크기 다루는 메커니즘 넷, 각자 다른 문제 해결. 어느 걸 잡을지 아는 게 중요.

Shallow clone (git clone --depth N) 이 가장 최근 N commit 만 다운로드. 가장 빠른 clone, 가장 작은 다운로드, 일회성 CI run + 데모에 유용. 비용: git blame, git bisect, 대부분 history query 가 부정확 / 불가능. 진짜 history 안 필요할 때만 shallow. 필요해지면 git fetch --unshallow 로 full history 승격.

Partial clone (git clone --filter=blob:none 과 친구들) 이 commit + tree object 만 다운로드, blob fetch 는 checkout 까지 미룸. Modern, Git 2.20 부터 가능. 대부분 workflow 에 shallow 보다 나음: blob 내용 안 필요한 history query 빠르게 유지, 파일 실제로 볼 때 blob 이 on-demand fetch. --filter=tree:0 가 tree 다운로드도 미룸, 매우 좁은 checkout 에 유용.

Sparse checkout 이 repo tree 의 어느 path 가 working 디렉토리에 실체화될지 선택. Partial clone 과 결합하면 거대 repo 에서도 작은 working tree. git sparse-checkout init --cone + git sparse-checkout set frontend/ docs/ 가 그 path 만 채움. Monorepo 가 엔지니어마다 집중된 workspace 주는 데 사용.

Git LFS ('Large File Storage') 가 큰 binary 파일 (영상, 데이터셋, 디자인 asset) 을 Git repo 의 작은 pointer 파일로 교체, 실제 binary 는 전용 LFS 서버에 살게. Binary 많은 프로젝트엔 필수 — Git diff / pack 이 텍스트 최적화라서. git lfs track "*.psd" 로 파일 타입 추적, git-lfs hook 한 번 설치, push/pull 이 자동으로 binary 를 LFS storage 로 라우팅.

Code

Shallow vs partial clone·bash
# Shallow — 빠름, history depth 없음:
git clone --depth 1 https://github.com/torvalds/linux.git
# git blame 과 bisect 가 제한됨.

# Partial — modern, lazy blob fetch:
git clone --filter=blob:none https://github.com/torvalds/linux.git
# 파일 실제 열 때 blob 이 on demand fetch.

# Tree-also-deferred (sparse-checkout 과 최고):
git clone --filter=tree:0 https://github.com/...

# Shallow → full history 승격:
git fetch --unshallow
Monorepo 집중을 위한 sparse-checkout·bash
# Clone 된 repo 안에서 cone mode 로 sparse-checkout init:
git sparse-checkout init --cone

# Working tree 에 이 path 만 실체화:
git sparse-checkout set frontend/web docs/api

# 나중에 path 추가:
git sparse-checkout add backend/auth

# Sparse-checkout 비활성화 (full tree):
git sparse-checkout disable

# Partial clone 과 결합 = monorepo 콤보:
git clone --filter=blob:none --sparse https://...
cd repo
git sparse-checkout init --cone
git sparse-checkout set my/team/path
큰 binary asset 용 Git LFS·bash
# 머신에 git-lfs 한 번 설치:
brew install git-lfs        # macOS
git lfs install              # 현재 사용자 hook 등록

# Repo 안에서 LFS storage 용 파일타입 표시:
git lfs track "*.psd"
git lfs track "*.mp4"
git add .gitattributes
git commit -m "Configure LFS for design + video assets"

# 평소처럼 push — git-lfs 가 가로채 binary 를 LFS 서버에 저장.

# 이 repo 의 LFS 콘텐츠 검사:
git lfs ls-files

External links

Exercise

큰 public repo (예: https://github.com/torvalds/linux.git) 두 방식으로 clone: --depth 1 shallow + --filter=blob:none partial. 둘 다 시간 측정, du -sh 로 디스크 사용량 기록. Partial clone 에서 최근 파일에 git log -p 돌려 lazy-fetch 동작 관찰. 더 작은 repo 에서 sparse-checkout 으로 서브디렉토리 하나만 실체화 설정. 일에 실제 채택할 메커니즘 + 이유 적어.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.