# Git and GitHub for Analysts

> Tracking SQL, notebooks and scripts with Git, branching, pull requests and sharing work on GitHub. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/data-analyst/git-basics
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/data-analyst/jupyter-notebooks)

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

- [Pro Git book](https://git-scm.com/book/en/v2) (git-scm.com)
- [GitHub Docs: Get started](https://docs.github.com/en/get-started) (GitHub)

Previous: [Diagnosing Metric Changes](https://www.internhack.in/roadmaps/tracks/data-analyst/metric-diagnosis) · Next: [Reproducible Analysis Projects](https://www.internhack.in/roadmaps/tracks/data-analyst/reproducible-projects)

## More in Version Control and Reproducible Workflow

- [Git and GitHub for Analysts](https://www.internhack.in/roadmaps/tracks/data-analyst/git-basics)
- [Reproducible Analysis Projects](https://www.internhack.in/roadmaps/tracks/data-analyst/reproducible-projects)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Analyst Roadmap](https://www.internhack.in/roadmaps/tracks/data-analyst)
