November 3, 2026 · krey

A Beginner Guide to Git and GitHub for Data Projects

Version control makes your work explainable and recoverable. For a student portfolio, Git is not just a way to upload files; it is a record of how a project changed and a practical habit used by collaborative teams.

Create a clean repository

Start with a README, a sensible directory structure, a dependency file and a licence or data-use note when appropriate. Keep notebooks, reusable source code, tests and reports separate. Never commit passwords, tokens, private data, large generated files or local environment folders.

Make focused commits

A commit should describe one coherent change: add data validation, improve the README, or fix a feature calculation. Write the message so a future reader understands the intention. Small commits are easier to review and revert.

git status
git add README.md src/
git commit -m "Document data preparation workflow"
git log --oneline

Use branches for experiments

When testing a change that may not work, create a branch. Keep the main branch runnable and merge only after checking the project. This is especially helpful when comparing feature definitions or model approaches.

Write a README for a new reader

Explain the project question, setup commands, data access, how to run the analysis, what output to expect and what limitations remain. If the data cannot be redistributed, provide an official source and a script or instructions for obtaining it.

References

A practical Git workflow

Create a branch for a focused change, make small commits with informative messages, and inspect the diff before pushing. Commit the source notebook or script, documentation and environment definition, but not secrets, large generated files or private datasets. A commit should explain one coherent change so it can be reviewed or reverted without guesswork.

Repository structure for a data project

A simple structure might include README.md, src/ for reusable code, notebooks/ for exploration, data/ with a documented acquisition step, tests/, and a dependency file. Keep paths configurable rather than embedding a personal computer path. Add a license and dataset attribution when appropriate.

Pull requests are documentation

Describe the question, important decisions, validation performed and known limitations in the pull request. Link to a reproducible result and call out any change that affects metrics. Reviewers can then assess both the code and the reasoning. Respond to feedback with a new commit or a clear explanation instead of silently changing unrelated files.

Recovering safely

Use git status and git diff before destructive commands. If a notebook contains accidental output or a secret, remove the secret from the file and rotate it; deleting the line in a later commit does not remove it from history. Learn revert and branch-based recovery before experimenting with history rewriting.