Why Git and GitHub Belong in Public Health: A Power BI Example
Table of Contents
Many public health teams still manage reports, scripts and documentation on a shared drive or a local machine, which makes it hard to see what changed, undo a mistake or work on the same file at the same time. This article shows how Git and GitHub solve that, through the story of three analysts putting a Power BI report under version control. The team gets a full history of who changed what and why, a clean way to roll back mistakes, and a review step before changes reach the live report. The workflow, a starter list of files to keep out of Git and the step-by-step walkthrough carry over to any report, script or analysis, on GitHub or alternatives like GitLab and Azure DevOps.
Introduction #
Imagine that a team at a public health unit (PHU) maintains a Power BI report on drinking water results. Someone tweaks a measure on Friday afternoon, and on Monday the report shows the wrong rates. Nobody is sure what changed. The shared drive holds water_report_final.pbix, water_report_final_v2.pbix and water_report_final_v3_REAL.pbix, and the person who made the change is on vacation.
Git is built for exactly this type of problem. It is a free tool on your computer that records every change you choose to save to a project, who made it and why, and lets you go back to any earlier version. GitHub is a website that stores a shared copy of that history, so it is backed up and a team can work on the same project without overwriting each other’s work.
This article introduces both Git and GitHub through the story of one small team working on one Power BI report.
A Brief Why #
The aim of this article is to convince you that Git is a tool worth adopting for public health work. Here are five reasons up front:
- Change history: track changes to code, reports and analyses, making it easy to see what changed, when and by whom.
- Reproducibility: recreate and validate an analysis using the exact code and data-processing steps that produced a published number.
- Collaboration: let several staff work on the same project at the same time without overwriting each other’s work.
- Auditability: keep a complete history of work, supporting quality assurance, compliance and transparent decision-making.
- Backup and recovery: protect projects, scripts and documentation by preserving earlier versions that can be restored.
Git: Version Control in a Nutshell #
If you use Microsoft Word and Excel, or Google Docs and Sheets, you already rely on saving and version history. Git applies the same idea to a whole project directory, where each “save” is deliberate and labelled.
The core Git routine: stage and commit your changes to a branch in the repository. Git uses some terms that can be a barrier at first. We’ll put each term in bold and define it when it first appears. The full list is in the glossary.
A repository (or repo) is a project directory that Git tracks. Git keeps the directory’s history in a hidden .git directory inside it, so your files look the same as before.
Git records the project as a series of snapshots, each called a commit. Each commit is a full snapshot of the project at that moment, so you can look at, compare or return to any of them. Strung together, a project’s Git snapshots make up its git history or commit history. Before you commit, you choose which changes go into the snapshot using a staging area. Each commit is saved to a branch, a separate copy of the history, and a new repository starts with a single main branch.
report.pbip make up the new commit, because the README.md edits were never staged- The working directory is the set of files in your project directory on disk. Saving a file in Power BI or a text editor changes the working directory. Git notices that these files differ from the last commit, but it hasn’t recorded anything yet.
- To stage (
git add) a change is to select it for the next snapshot. Staging lets you commit some changes and leave others for later: in the diagram, the change toREADME.md(a short text file describing the project) is left out of this commit. If you edit a file again after staging it, stage it again to include the new edits. - To commit (
git commit) is to save a snapshot of every staged change into the project’s history, with a short message describing what changed and why. Each commit also gets a unique ID called a hash (usually shown shortened, for example3f9c2ab), so it can be referenced later.
At any point, status (git status) shows which branch you’re on (branches are explained in more detail below) and which edits are staged or not. When in doubt, run it. VS Code, a free Microsoft editor with built-in Git buttons, shows the same information on screen in its Source Control panel1.
See it →
Nate Starts a Project #
Suppose Nate, Eswar and Tia plan to improve an existing Power BI report together. They also want to keep a working report live for the rest of the team while they build and test new features.
Power BI reports save by default as a single .pbix file. Because of the file format, Git can detect when it changes but cannot meaningfully compare versions to show what changed. A .pbix with imported data also contains the data itself. Power BI’s project format, PBIP, saves the same report as a small .pbip file plus two directories of plain-text files (one for pages and visuals, one for measures and the data model), so Git can show exactly which lines changed. To use it, choose File → Save as and pick Power BI project files (*.pbip). If that option isn’t listed, turn it on under File → Options and settings → Options → Preview features.
Nate:
- Creates an empty directory and makes it a repository with init (
git init). See it → - Saves the current report into that directory in PBIP format. Power BI automatically adds a
.gitignorefile, a list of files Git should never track; Nate adds the starter entries to keep data and credentials out of Git. See it → - Stages all the new files. See it →
- Commits them with the message “Add existing water report as PBIP”. See it →
Saving the report in step 2 puts the files on disk, but nothing enters the Git history until the deliberate commit in step 4. Every new repository starts with a single branch, a separate line of work, called main (more on branches next), so after step 4 the history looks like this:
Branching and Merging #
A branch is a separate line of work: commits on one branch can change files while the same files stay untouched on another. When you switch your current working branch to another, Git switches the files in your directory to match that branch. Doing new work on its own branch keeps the version on main working. You create and switch to a new branch with git switch -c <name>. When the work is finished, the branch is merged (git merge) into another branch, usually main, which adds its commits to that branch’s history.
Nate continues:
- Creates a branch named
fix-date-filtersfrommain. See it → - Makes an edit and commits it on
fix-date-filters. - Merges
fix-date-filtersintomain. See it →
During step 6, main stays unchanged: if Nate switches back to main, the report opens exactly as it was. Only after the merge in step 7 does main include Nate’s new work:
main are unchanged until fix-date-filters is merged into mainUndoing a Mistake #
A week later, the report shows exceedance rates that are far too high. This is the Friday-afternoon problem from the introduction, but this time the answer is in the history rather than in the memory of a colleague on vacation. Log (git log) lists every commit with its hash, author, date and message. Nate spots a recent commit, “Change exceedance rate measure”, made directly on main without a branch or review. Opening that commit (git show <hash>, or clicking it in VS Code) shows that the new measure divides by the wrong column.
See it →
Instead of fixing it by hand, Nate uses revert (git revert <hash>), which creates a new commit that undoes exactly that change. The history stays complete: anyone can see that the mistake happened, when, and how it was fixed, which is the kind of audit trail that quality assurance depends on.
The mistake reached main because nobody reviewed it. The pull requests and branch protection described below are designed to catch this kind of change before it reaches the live report.
This is the core of Git. Its bigger payoff comes from connecting your local repository to a shared one.
Collaborating with GitHub #
Perhaps you’ve lost work because a file was accidentally deleted, a drive became unavailable or a laptop died. Remote repositories are designed to prevent this. A remote is a copy of the repository hosted somewhere else, so the work doesn’t depend on any one machine, and others can work on the same project.
GitHub is often confused with Git itself. Git is the tool that records history on your computer; GitHub is a website (owned by Microsoft) that hosts copies of Git repositories and adds tools for teams to work on them together. It is the most widely used platform of its kind; others include GitLab, Bitbucket and Azure DevOps. Many public sector organizations publish projects on GitHub, such as Statistics Canada2, the Government of Ontario3, the Public Health Agency of Canada’s (PHAC) National Microbiology Laboratory4 and the PHAC Modelling Hub5. GitHub also hosts private repositories that only invited members can see. GitHub.com stores repositories outside Canada, so check with your IT and privacy teams before your organization starts using it, even for private repositories.
Three actions keep local and remote copies in sync:
- To push (
git push) is to send your new local commits to the remote. - To pull (
git pull) is to bring new commits from the remote into your local copy. - To clone (
git clone <url>) is to download a full copy of an existing remote repository, history included, for the first time.
The report is internal, so Nate creates a private repository under the organization’s GitHub account, where Eswar and Tia are members. Continuing the steps:
- Nate pushes the repository to the organization’s GitHub. See it →
- Eswar and Tia can now each begin on their own machines building on this work. See it →
Now on Eswar’s machine:
- Clones the repository.
- Creates a branch called
feature-water-page. - Builds a new page on that branch, making several commits.
- Pushes the branch to GitHub.
- Opens a pull request proposing to merge
feature-water-pageintomain. See it → - Tia and Nate review the changes, suggest edits and automated checks run.
- The pull request is merged into
main. See it →
Steps 5 to 7 happen on GitHub. The team doesn’t merge straight into main. Instead, they open a pull request (PR): a page on GitHub that proposes merging one branch into another, describes the changes, lets teammates comment and review, and runs any automated checks before anything reaches main. Despite the name, a pull request is not the same as git pull: you are asking the team to pull your branch into theirs. Once reviewers approve and the checks pass, the PR is merged (or closed without merging if the change isn’t wanted).
Because each branch now exists in two places, on Eswar’s machine and on GitHub, the copies can drift apart. After Eswar commits locally, the local branch is ahead of the GitHub copy until Eswar pushes. When a teammate pushes to main, Eswar’s local main is behind until Eswar pulls. VS Code shows both counts in its status bar.
See it →
main are unchanged until PR #1 is mergedMerging into main doesn’t change the report colleagues see in the Power BI Service. Someone still has to publish from main as usual, or, on Fabric or Premium capacity, the workspace can sync with the repository through Git integration.
Some Words of Caution #
Merge Conflicts #
A merge conflict happens when two branches change the same part of the same file and Git can’t tell which version to keep. Suppose Tia and Nate both edit the exceedance rate measure on separate branches. Each commit works fine on its own branch, but when the second branch is merged (or pulled), Git stops and marks the conflicting lines. Someone has to choose the correct version, or combine the two, and commit the result before the merge can finish. See it → Merging small changes often and pulling before you start work keep conflicts rare and small.
Handling Sensitive Data #
Git history is designed to be permanent. Deleting a file in a later commit does not remove it from earlier commits, and once a commit is pushed, every clone has a copy. This matters especially for public health teams, because two kinds of sensitive material must never be committed:
- Secrets: passwords, API keys (codes that let a program sign in to a service), access tokens and database connection strings (addresses that can include a username and password). Anyone who sees a secret can use it. A common example is an API key pasted into a Power Query web source URL.
- Personal health information (PHI): any record that could identify an individual and reveals details about their health or health care, including line lists, extracts and other client-level records. Committing PHI where people without a need to know can see it is an unauthorized disclosure, and can be a privacy breach under Ontario’s Personal Health Information Protection Act, 2004 (PHIPA). Once exposed, it can’t be taken back.
Preventing It #
The first line of defence is the .gitignore file which defines a list of files and directories Git should never track for this project. Power BI creates one for its local cache files when you save as PBIP; add your own entries for data directories, .env files (small text files that hold settings and passwords) and anything else holding passwords or keys. A starter .gitignore is below. It only covers the patterns it lists, so still check what you stage. Also:
- Keep secrets out of the files. In Power BI, enter credentials only when Power BI asks for them (they are stored in Data source settings, outside the project), and never paste keys into URLs, parameters or M code. In R or Python scripts, read secrets from environment variables, an ignored
.envfile or your organization’s secret manager (such as Azure Key Vault), so the code only ever holds a name likeWATER_API_KEY, never the value. - Keep data out of the project directory. Connect reports to governed sources (a database, SharePoint or a secured network share) rather than to files copied next to the code.
- Turn on GitHub’s secret scanning and push protection where your plan allows. Push protection blocks a push that contains a recognizable key before it reaches GitHub. Both are free for public repositories; private repositories need GitHub’s paid Secret Protection add-on.
- Add a pre-commit hook: a small check that runs on your own machine each time you commit, here to scan for secrets. Tia’s excellent article on CI/CD and pre-commit shows how to set one up.
If It Happens Anyway #
Suppose Nate starts a second project and hasn’t added the starter .gitignore yet. He stages everything at once and accidentally commits the data/ directory, which contains client-level records, along with a .env file holding an API key.
If he notices before pushing, the fix is local and quick. git reset HEAD~1 (HEAD~1 means “one commit back”) undoes the last commit while keeping the files on disk; in VS Code, the same action is Undo Last Commit, under Commit in the Source Control … menu. He then adds data/ and .env to .gitignore and commits again. Nothing left his machine. For more on undoing local mistakes, see the Pro Git chapter on undoing things6.
If the commit has already been pushed to a public repository, anyone on the internet may have seen it, so treat it as an incident, not a cleanup task:
- Assume it’s compromised immediately: exposure starts at the push, and bots scan public repositories for keys within minutes.
- Contain it: make the repository private, review who has access and ask collaborators not to pull, clone or fork it.
- Escalate promptly: follow your organization’s privacy breach protocol.
- Revoke secrets at the source: revoke and replace the key with the service that issued it, since committing a replacement leaves the old one working in the history.
- Preserve evidence: record what was exposed, the commit hash, when it was pushed and who had access, stored outside the repository.
- Investigate misuse: check the service’s access logs and GitHub’s audit log for activity during the exposure window.
- Remove it from history: with IT’s agreement, follow GitHub’s guide to removing sensitive data from a repository7 and have everyone clone again.
- Fix the cause: find out how the file got into the project and add the prevention steps above so it can’t happen again.
Do steps 1 to 4 straight away, in parallel if you can.
A private repository is visible only to the people and teams granted access, so the exposure is limited to them rather than the public, and the containment in step 2 is mostly done already. It is still an exposure, though: PHI should be removed from Git history, and a secret should be revoked and replaced. Escalate, preserve evidence and clean the history in the same way, with less urgency about outside misuse.
Good Git #
Alongside .gitignore, these habits make Git and GitHub work well for a team:
- Commit small, logical changes. One purpose per commit makes review, debugging and reverting easier.
- Write messages for your future self. “Fix exceedance rate denominator” beats “updates”.
- Set up
.gitignorebefore the first commit. It’s far easier than cleaning up history later. - Pull before you start. Begin each session from the latest version to avoid conflicts.
- Use one branch per change. Keep
mainworking and do new work on a branch. - Protect
main. Use GitHub’s branch protection rules to require a reviewed pull request before anything merges. On private repositories, this needs a paid plan such as GitHub Team. - Check before you commit. Run
git status(or glance at Source Control) to see exactly what is staged, and usegit logor VS Code’s graph view to see where you are.
Beyond the Basics on GitHub #
- Issues: track bugs, requests and tasks alongside the code.
- Projects: plan and prioritize work on a board built from issues and pull requests.
- Actions: run automated checks, tests and other custom workflows on every push or pull request. Tia’s excellent article on CI/CD and pre-commit shows how.
- Pages: publish a static website, such as documentation, straight from a repository.
Reuse It in Your PHU #
What you can copy: the branch → pull request → merge workflow, the
walkthrough commands and this starter .gitignore for Power BI projects. Keep the sections that apply to your project, and adjust the data patterns to fit your directory layout, for example if a small lookup table should be tracked.
# If sensitive data is present:
# Data and extracts: never commit client-level data
data/
*.csv
*.xlsx
*.parquet
# If working on a Power BI report:
# Power BI: .pbix files and local cache can hold data
# (PBIP adds the two .pbi entries automatically)
*.pbix
**/.pbi/localSettings.json
**/.pbi/cache.abf
# If credentials are present:
# Credentials and local settings
.env
*.pem
*.key
Git, VS Code and Power BI Desktop’s PBIP format are free, and GitHub’s free organization plan includes private repositories. A safe pilot is one existing report, one private repository, two or three people, and branch protection on main from day one. Nothing here is specific to Power BI either: R, Python, SQL and Quarto projects follow the same steps.
Limits #
- Some Power BI changes are hard to review: pages and visuals are stored as long JSON files, so a small layout tweak can produce a large, hard-to-read diff, and conflicts in those files are tedious to resolve. Agreeing who is working on which page avoids most of them.
- Git is for code and documents, not datasets: data files and large binary files bloat a repository and may contain PHI. Keep data in governed storage; tools like DVC (Data Version Control)8 can version data without putting it in Git.
- There is a learning curve: branches, pull requests and the occasional conflict take practice. GitHub Skills9 offers free, interactive courses for practising them. Starting with a simple, agreed team workflow matters more than knowing every command.
Conclusion #
Version control is a small daily habit that supports larger goals for public health modernization: analyses that can be reproduced, reports with an audit trail, and work that doesn’t depend on one person’s laptop or memory. Because Git is open source and the workflow is the same on every platform, it also travels well between PHUs.
- Try it! Pick one report your team maintains, save it as PBIP, and put it in a private repository with the starter
.gitignoreand branch protection onmain. Then make the next change to it through a pull request, even if the only reviewer is one colleague. The step-by-step walkthrough covers each action; practise on a copy first. - Share back! If you adapt the starter
.gitignoreor settle on a team workflow, we’d like to hear what worked and what didn’t. Our open projects are on GitHub10. - Get help! If your team wants support piloting Git and GitHub, contact us.
Glossary
- Ahead / behind: how many commits your local branch has that the remote doesn’t (ahead), or the remote has that you don’t (behind).
- Branch: a separate line of commits, so work can happen without changing other branches.
- Clone (
git clone): download a full copy of a remote repository, including its history. - Commit (
git commit): save a snapshot of staged changes into the history, with a message. - Commit history: the chain of commits that records every saved version of the project.
- Fork: a personal copy of someone else’s repository on GitHub.
- Git: a free, open-source tool that records the history of a project directory on your computer.
- GitHub: a website that hosts Git repositories and adds team tools such as pull requests.
.gitignore: a file listing files and directories Git should never track, such as data and credentials.- Hash: the unique ID Git gives each commit (for example
3f9c2ab). - HEAD: Git’s name for the commit you currently have checked out;
HEAD~1is the one before it. - Init (
git init): turn a directory into a repository. - Log (
git log): list the commits in the history with their hash, author, date and message. main: the default branch, which usually holds the working, shareable version of the project.- Merge (
git merge): combine the commits from one branch into another. - Merge conflict: when two branches change the same lines and a person must choose the result.
- PBIP: Power BI’s project format, which saves a report as text files Git can track.
- Personal health information (PHI): identifying information about an individual’s health or health care, protected under PHIPA in Ontario.
- Pre-commit hook: a check that runs automatically on your machine each time you commit.
- Pull (
git pull): bring new commits from the remote into your local copy. - Pull request (PR): a GitHub page proposing to merge one branch into another, with review and discussion.
- Push (
git push): send your new local commits to the remote. - README: a short text file, usually
README.md, that describes a project. - Remote: a copy of the repository hosted elsewhere, such as on GitHub.
- Repository (repo): a project directory tracked by Git, with its history stored in a hidden
.gitdirectory. - Revert (
git revert): add a new commit that undoes an earlier commit. - Secret: a password, API key, token or other credential that grants access to a system.
- Stage (
git add): pick changes to include in the next commit. - Staging area: the holding area for changes picked for the next commit.
- Status (
git status): show the current branch and which changes are staged or unstaged. - VS Code (Visual Studio Code): a free code editor from Microsoft with built-in Git buttons.
- Working directory: the project files as they currently exist on your disk.
Extras
These commands weren’t needed for the team’s story, but they come up periodically once Git becomes a habit. The Git cheat sheet11 provides a single resource for all these commands.
- Diff (
git diff): show the exact lines changed in the working directory that aren’t staged yet. Add--stagedto see what will go into the next commit. - Restore (
git restore <file>): throw away unstaged edits to a file and return it to its last committed version.git restore --staged <file>unstages a file but keeps the edits. Discarded edits can’t be recovered, so check withgit difffirst. - Show (
git show <hash>): display one commit’s message and the changes it made. - Blame (
git blame <file>): show who last changed each line of a file and in which commit, useful for tracing when a measure or query changed. - Tag (
git tag <name>): give a commit a permanent, readable label, such asv2026-q3-release, to mark the exact version behind a published report. Push tags withgit push --tags. - Stash (
git stash): set your uncommitted changes aside so the working directory is clean, for example to switch branches or pull before you’re ready to commit.git stash listshows what’s been set aside. - Stash pop (
git stash pop): bring the most recently stashed changes back into the working directory and remove them from the stash.
A typical stash workflow, when a teammate’s fix lands on main while you’re mid-edit on your own branch:
# Set aside your unfinished edits (recoverable)
git stash
# Update main with the latest changes from GitHub
git switch main
git pull
# Return to your branch
git switch feature-water-page
# Bring in the fix from main
git merge main
# Restore your edits
git stash pop
VS Code: stash and pop are in the Source Control … menu under Stash; diff opens when you click a changed file; Discard Changes (the curved arrow on a file) is the same as git restore.
Visual Studio Code, “Source control in VS Code” — https://code.visualstudio.com/docs/sourcecontrol/overview ↩︎
Statistics Canada on GitHub — https://github.com/StatCan ↩︎
Government of Ontario on GitHub — https://github.com/ongov ↩︎
National Microbiology Laboratory on GitHub — https://github.com/phac-nml ↩︎
PHAC Modelling Hub on GitHub — https://github.com/phac-modelling-hub/ ↩︎
Pro Git, “Git Basics – Undoing Things” — https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things ↩︎
GitHub Docs, “Removing sensitive data from a repository” — https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository ↩︎
DVC (Data Version Control) — https://dvc.org/ ↩︎
GitHub Skills — https://github.com/skills ↩︎
Wellington-Dufferin-Guelph Public Health on GitHub — https://github.com/WDGPH ↩︎
Git, “Git Cheat Sheet” — https://git-scm.com/cheat-sheet ↩︎