+91 99301 12627
MLOps & Cloud

Git and GitHub for Data Scientists: A Practical Beginner’s Guide

By Mehul Prajapati

Aerial view of a branching road representing Git branches for data science projects
On this page

Short answer: Git tracks changes to your code so you can save versions, undo mistakes and collaborate; GitHub hosts your repositories online. For data science, learn the core workflow (git init/clone, add, commit, push, pull), use branches and pull requests for teamwork, keep datasets, model files and secrets out of Git with .gitignore, and manage notebooks carefully. A clean GitHub profile with documented projects also works as your portfolio.

Key takeaways

  • Commit code, not data or secrets.
  • Use branches for experiments and features.
  • Write a README for every project.
  • For large data and models, use tools like DVC or cloud storage.

Why data scientists need Git

  • Reproduce results by returning to the exact code version
  • Experiment safely on branches
  • Collaborate with engineers who expect Git workflows
  • Required for CI/CD and MLOps
  • Showcase work to recruiters on GitHub

Essential commands

git init                      # start tracking a folder
git clone <repo-url>          # copy a remote repository
git status                    # see what changed
git add train.py              # stage a file
git commit -m "Add baseline model"
git push origin main          # upload to GitHub
git pull                      # get latest changes
git log --oneline             # view history

Branching workflow

git checkout -b feature/xgboost-model
# ...edit and commit...
git push -u origin feature/xgboost-model
# open a Pull Request on GitHub, get review, then merge

Pull requests let teammates review code, comment and run automated tests before changes reach the main branch.

A .gitignore for data science projects

# data and models
data/
*.csv
*.parquet
models/
*.joblib
*.pt

# secrets and environments
.env
.venv/
__pycache__/
.ipynb_checkpoints/

Never commit API keys. If a key is pushed by mistake, revoke it immediately; deleting the file later does not remove it from history.

Working with Jupyter notebooks

  • Clear large outputs before committing to keep diffs readable
  • Move reusable code into .py modules
  • Tools like nbstripout remove outputs automatically; jupytext pairs notebooks with plain scripts

Large files and data versioning

  • GitHub limits individual file sizes, so keep large data out of normal Git
  • Git LFS stores large files outside the main repository
  • DVC versions datasets and models alongside Git, with storage in the cloud
project/
├── README.md
├── requirements.txt
├── data/            # ignored
├── notebooks/
├── src/
│   ├── features.py
│   └── train.py
└── tests/

GitHub as your portfolio

  • Pin 3–6 best projects on your profile
  • Each README: problem, data, approach, results, how to run
  • Include charts, metrics and a short business conclusion
  • Add deployed demos where possible (for example a Dockerised API)

Project ideas: data science projects for beginners.

Frequently asked questions

Git vs GitHub?

Git is the version-control tool on your computer; GitHub is an online platform that hosts Git repositories and adds collaboration features.

Should I commit datasets?

Generally no. Commit small sample data if needed for tests; store full datasets in cloud storage or version them with DVC.

How do I undo my last commit?

git revert HEAD safely creates a new commit that undoes it; avoid rewriting shared history.

Is Git asked in data science interviews?

Basic Git is often assumed, and ML engineering roles regularly test it.

Conclusion

Git for data science is about reproducibility, collaboration and credibility. Learn the core commands, keep data and secrets out of your repositories, use branches and pull requests, and turn GitHub into a portfolio that shows how you work.

Learn Git, CI/CD and MLOps hands-on in our Data Science course.

Learn with Mehul Prajapati in Borivali West

At Mehul Prajapati’s institute, you get 100% practical, hands-on training by industry experts with a minimum of 5+ years of experience, plus job-oriented programmes with placement support. Weekday and weekend batches are available, with multiple 2-hour slots between 8 am and 6 pm.

Address: 12th Floor, 1214, Gold Crest Business Centre, LT Rd, Above Westside Showroom, Borivali West, Mumbai, Maharashtra 400092
Call: +91 99301 12627 / +91 96645 45072

Visit the centre or call us to choose the right course and batch and to know the current fee structure.