Why this matters
As a BI Analyst, you change SQL queries, dbt models, notebooks, and dashboard definition files. Branching lets you work safely without breaking main. Pull requests (PRs) let teammates review, test, and approve changes before they go live.
- Collaborate on complex KPI definitions without overwriting each other.
- Propose report updates, get feedback, and track what changed and why.
- Fix urgent production bugs quickly and cleanly.
- Keep a clear history so audits and rollbacks are easy.
Concept explained simply
A branch is a separate line of work. The main branch is the stable source of truth. You create a feature branch to make changes. A pull request is a formal proposal to merge your branch back into main after review.
Mental model
Imagine main as the highway. A branch is a safe exit where you can tinker with your car. When it’s ready, the PR is the checkpoint that verifies your car is safe before you rejoin the highway.
Core workflow
- Update local main:
git checkout mainthengit pull. - Create a branch:
git checkout -b feat/new-kpi. - Make changes; commit early and often.
- Push the branch:
git push -u origin feat/new-kpi. - Open a PR, add context, request review.
- Address feedback, resolve conflicts, then merge when approved.
- Delete the branch after merge to keep things tidy.
Worked examples
Example 1: Add a new KPI definition
- Start from the latest main:
git checkout main git pull - Create a branch:
git checkout -b feat/new-kpi-dau - Edit
models/kpis/daily_active_users.sql. - Commit and push:
git add models/kpis/daily_active_users.sql git commit -m "feat: add DAU KPI using 7d activity window" git push -u origin feat/new-kpi-dau - Open a PR, describe why the KPI matters, how to validate, and any data quality checks.
What just happened?
You isolated your work, documented intent in the commit message, and created a reviewable change. Reviewers can run tests or preview reports before merging.
Example 2: Hotfix a broken dashboard filter
- Update main and branch for a fix:
git checkout main git pull git checkout -b fix/dashboard-filter-bug - Edit the affected file (e.g.,
dashboards/sales.json) to correct the filter. - Commit and push:
git add dashboards/sales.json git commit -m "fix: correct region filter to include EMEA" git push -u origin fix/dashboard-filter-bug - Open a PR with clear reproduction steps and the fix verification steps.
Tip: Keep hotfix PRs small
Limit the change to the minimum needed to fix production. Larger refactors should be separate feature PRs.
Example 3: Team collaboration on a dbt model change
- Create a branch:
git checkout -b feat/refactor-orders-model - Commit work in small steps:
git commit -m "refactor: split orders into base + dims" # after tests git commit -m "test: add freshness checks for orders_base" - Push and open a PR. Use a checklist in the description (tests passing, docs updated, owners notified).
- Respond to review comments with follow-up commits until approved.
Review checklist suggestion
- Does the query run within expected time?
- Are column definitions, docs, and tags updated?
- Could this affect downstream dashboards?
Branch naming patterns and commit messages
- Branches:
feat/...for new work,fix/...for bugs,chore/...for maintenance. Examples:feat/new-kpi-dau,fix/null-customer-id. - Commits: Use a short, imperative summary and optional body. Example:
feat: add DAU KPI - counts active users with 7-day window - used by exec dashboard
Merge conflicts: simple resolution
Conflicts happen when two branches change the same lines. Git marks conflicts like this:
<<<<<<< HEAD
-- your version --
=======
-- incoming version --
>>>>>>> origin/main- Edit the file to keep the correct lines and remove the markers.
- Stage and continue:
git add path/to/file.sql git commit -m "chore: resolve merge conflict in file.sql"
Self-check for conflicts
- Did you remove all markers (<<<<<<<, =======, >>>>>>>)?
- Did the file still run or compile after resolving?
Exercises you can do now
These match the exercises at the bottom of the page. Do them in a sample repo or a new test repository you create locally.
Exercise 1: Feature branch and PR
- Create branch
feat/add-revenue-kpifrom updated main. - Add or modify a SQL file to compute a revenue KPI.
- Commit and push; open a PR with a clear description and validation steps.
What to include in the PR
- What changed and why (business impact).
- How reviewers can test it (query, filters, date range).
- Any downstream dashboards affected.
Exercise 2: Resolve a merge conflict
- On your branch, edit the same lines in a file that you also edit on main (simulate a conflict).
- Merge main into your branch and resolve the conflict.
- Commit the resolution and push updates to the PR.
Checklist to finish
- All conflict markers removed.
- Queries run successfully.
- PR shows no merge conflicts.
Common mistakes and self-check
- Working directly on main. Fix: always branch from updated main.
- Large PRs with mixed changes. Fix: split into small, focused PRs.
- Vague commit messages. Fix: describe intent and scope.
- Forgetting to pull before branching. Fix:
git checkout main && git pullfirst. - Ignoring failed checks/tests. Fix: make tests pass before merge.
Quick self-audit
- Can a teammate read your PR and understand why it exists?
- Is the PR small enough to review in under 15 minutes?
- Can you revert your branch without affecting main?
Practical projects
- Analytics KPI Pack: Add 3 new KPIs in separate branches and open 3 PRs. Merge them sequentially after reviews.
- Dashboard Refactor: Split a large query into modular parts in a feature branch. Include a PR checklist for docs and tests.
- Hotfix Drill: Simulate a production bug, fix it with a small
fix/branch, and document validation steps in the PR.
Who this is for
- BI Analysts and Analytics Engineers new to Git collaboration.
- Analysts who currently share SQL via files or chats and want safer teamwork.
Prerequisites
- Basic Git commands: init, add, commit, status.
- Basic terminal/CLI usage.
- A sample repository with at least one SQL or model file.
Learning path
- Initialize and commit locally.
- Learn branching and PR basics (this lesson).
- Practice conflict resolution and code review etiquette.
- Adopt PR checklists and small, frequent merges.
Next steps
- Automate simple checks (lint SQL, run tests) in your PRs.
- Create a team PR template with business impact, test steps, and owners.
- Set naming conventions for branches and labels.
Mini challenge
Pick one of your existing reports. In a new feat/ branch, improve a KPI definition or add a filter. Open a PR with:
- A clear one-sentence summary of the change.
- Three bullet points on how to validate it.
- Potential downstream impacts.
Optional: Ask a teammate to review and leave one improvement suggestion.
Progress saving note
The quick test below is available to everyone. If you are logged in, your test progress and results will be saved automatically.