Git and GitHub for Analysts

Tracking SQL, notebooks and scripts with Git, branching, pull requests and sharing work on GitHub.

Beginner · about 5 hours · difficulty 2/5

Learn first: Jupyter Notebooks and Reproducible Work

Analysts who keep queries in random files lose work and cannot explain how a number was produced last quarter. Git fixes that, and a GitHub profile doubles as your portfolio.

The everyday loop

git clone <repo-url>
git switch -c churn-analysis
# edit queries and notebooks
git add queries/churn.sql
git commit -m "Add 90-day churn query by channel"
git push -u origin churn-analysis

Then open a pull request so a teammate can review the logic before it feeds a dashboard.

What to commit

  • SQL files, Python or R scripts, notebooks, dbt models, README and documentation.
  • Not raw data dumps, credentials or large outputs. Use a .gitignore for data/, .env and output folders.

Notebooks in Git

Notebooks store outputs and metadata that create noisy diffs. Clear outputs before committing, or use tools like nbstripout or jupytext to keep diffs readable.

Good habits

  • Small commits with messages that say what and why.
  • One branch per analysis or change.
  • Review each other's SQL in pull requests; many metric bugs are caught here.
  • Tag or note the commit used for a published result so it can be reproduced.

Pitfall: committing a CSV with customer emails or a database password. Once pushed, assume it is exposed. You are ready to move on when you can branch, commit, push, open a pull request and resolve a simple merge conflict.

Key concepts

  • Repositories, commits and history
  • Branches and merging
  • GitHub remotes, push and pull
  • Pull requests and code review
  • .gitignore for data and secrets
  • Notebooks in version control
  • Resolving merge conflicts

Mini project

Put one of your analyses in a GitHub repo with a clear README, a .gitignore for data and secrets, and at least one pull request that you review and merge.

Check yourself

What should never be committed to an analytics repository, and how do you prevent it?

Free resources