27. How to Use Git with Jupyter Notebooks for Data Projects
27.1 Why Git for Notebook Data Projects
Why. Ruhi emails pune_eda_final2.ipynb. Amir edits a copy called pune_eda_final2_amir.ipynb. On Monday nobody knows which file built the Diwali chart. Git stores history — who changed what, and you can go back.
What.
- Repository (repo) — a project folder tracked by Git.
- Commit — a snapshot with a message.
- Remote (optional) — GitHub/GitLab copy for backup and teammates.
How.
Mindset for analysts
- One project folder = one repo.
- Code + notebook logic in Git; large raw data usually out.
- Commit when a small unit works (“city filter fixed”), not once a month.
- Pull/push only when you use a remote — local Git still helps alone.
- Treat secrets like production passwords (Chapter 24 / 26 habits).
Worked example A — Bad naming (fictional).
eda.ipynb → eda_v2.ipynb → eda_v2_FINAL.ipynb → eda_v2_FINAL_use_this.ipynb. Git replaces this mess with commits.
Worked example B — Good story.
commit 1: add raw sample + empty notebook
commit 2: clean city names for Maharashtra
commit 3: add Pune vs Nashik GMV chart
Worked example C — What Git is not in this chapter.
Not a full DevOps course. Not branching strategy for 50 engineers. Just enough so your Blinkit lab is reproducible.
Ravindra Bagale's Tip
File names like final_v3.ipynb are a warning sign, because soon nobody knows which file made the chart. Let Git keep the history, and write a clear commit message each time a small piece works, so you can go back to that exact point later. Git is for your code and notebook logic, not for multi-GB raw data dumps.
Ravindra Bagale's Tip – मराठी
final_v3.ipynb सारखी file नावं धोक्याची घंटा आहेत, कारण लवकरच कोणत्या file ने chart बनवला ते कुणालाच कळत नाही. History Git ला सांभाळू द्या, आणि प्रत्येक वेळी एखादा छोटा भाग चालू लागला की स्पष्ट commit message लिहा, म्हणजे नंतर नेमक्या त्या टप्प्यावर परत जाता येईल. Git तुमच्या code आणि notebook logic साठी आहे, multi-GB raw data dumps साठी नाही.
Ravindra Bagale's Tip – हिंदी
final_v3.ipynb जैसे file नाम ख़तरे की घंटी हैं, क्योंकि जल्द ही किसी को पता नहीं रहता कि chart किस file से बना। History को Git संभालने दो, और हर बार जब कोई छोटा हिस्सा चल जाए तो साफ़ commit message लिखो, ताकि बाद में ठीक उसी जगह वापस जा सको। Git आपके code और notebook logic के लिए है, multi-GB raw data dumps के लिए नहीं।