← Back to Git Course | Chapter 10: Tools & Internals | Lesson 6 of 8

Git Large File Storage (LFS)

Git LFS एक warehouse में stored एक heavy piano की ओर point करने वाला एक छोटा note छोड़ने जैसा है, ताकि project carry करते समय आपका backpack हल्का रहे।
Syntax
bash
git lfs install
git lfs track "*.extension"
git add .gitattributes

Git LFS क्या है?

Git text files के लिए designed है। बड़ी binary files (जैसे videos, datasets, या graphics) store करना cloning धीमा कर देता है। Git LFS (Large File Storage) इन files को आपकी repository में lightweight, 1KB text pointer files से replace कर देता है, cookiescursor.com जैसे servers पर clone speeds को तेज़ रखते हुए।

उदाहरण: What is Git LFS?

bash
git lfs install

Large Files Track करना

git lfs track "*.psd" (या कोई भी glob pattern) एक file type को LFS द्वारा handle होने के लिए register करता है, rule को एक .gitattributes file में लिखते हुए जो खुद repo में committed होती है — इसलिए एक बार कोई इसे set up कर दे, project clone करने वाला हर कोई automatically same LFS behavior पाता है।

उदाहरण: Tracking Large Files

bash
git lfs track "*.psd"
git add .gitattributes

LFS Files Stage और Commit करना

tracking configured होने पर, git add और git commit exactly normally काम करते हैं — LFS behind the scenes matching files intercept करता है, उनका actual content LFS storage में upload करता है, और इसकी जगह regular Git history में एक छोटी pointer file (file के hash और size वाली) commit करता है।

उदाहरण: Staging and Committing LFS Files

bash
git add design.psd
git commit -m "Add design file"

LFS Status Check करना

git lfs ls-files list करता है कि आपकी working directory में कौन सी tracked files इस समय LFS द्वारा managed हैं, और git lfs status दिखाता है कि उनमें से किनके pending changes हैं — यह confirm करने के लिए उपयोगी कि एक बड़ी file actually LFS से route हो रही है और गलती से एक regular blob की तरह commit नहीं हुई।

उदाहरण: Checking LFS Status

bash
git lfs ls-files
git lfs status

LFS Repositories Clone करना

LFS इस्तेमाल करने वाली एक repository clone करते समय, Git पहले lightweight pointers download करता है, फिर automatically LFS storage server से actual बड़ी files fetch करता है। यह cloning process को तेज़ और efficient रखता है।

उदाहरण: Cloning LFS Repositories

bash
git clone https://github.com/user/repo.git
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. पहले से commit हो चुकने के बाद एक file को git lfs track से track करना, जबकि पुराना version अभी भी एक normal file की तरह store है।
  2. .gitattributes commit करना भूल जाना, ताकि teammates उन files के लिए LFS इस्तेमाल न करें।
  3. बिना Git LFS installed के clone करना, ताकि बड़ी files छोटी pointer text files की तरह दिखें।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.