ETC5513: Collaborative and Reproducible Practices
Workshop 7
Workshop: Git LFS, Big Files, and Recovery
🧭 Goal
Understand: - Why Git can’t handle big files normally - How to recover if you accidentally try to commit something too big - The basics of Git LFS
Setup
Create a new GitHub repository:
git-lfs-practice
Clone it to your computer using RStudio:
- File → New Project → Version Control → Git
- Paste the repo URL
Simulate a Mistake: Add a Huge File
1l. Download the zip file from the Week 8 Moodle website
Try to Commit the Huge File
- Stage
bigfile.txt
- Try to commit it.
🔵 Expected Result:
GitHub will likely reject the push (file too large >100MB), or your Git client will warn you.
✅ You’ve hit a real size limit!
Try to Fix It With git revert
Try to revert the bad commit:
git revert HEAD
🔵 Expected Result:
Git won’t let you — because the giant file is still in the commit history.
⚠️ Key point: git revert
adds new commits; it doesn’t erase old ones.
Actually Fix It With git reset
Do a soft reset to move back before the bad commit:
git reset --soft HEAD~1
Now unstage the big file manually in RStudio (or):
git restore --staged bigfile.txt
Delete
bigfile.txt
from your project folder.Commit the new clean state:
"Remove large file after reset"
Install Git LFS
Install Git LFS:
Follow instructions here → https://git-lfs.github.com/Track large files safely:
git lfs install git lfs track "*.csv"
Then commit/push files as usual — Git LFS manages the storage.
Summary
Problem | Solution |
---|---|
Committed a huge file | git reset + delete manually |
Need to work with big files safely | Use Git LFS |
🎉 You survived a Git crisis — just like real developers do!