Git Refresher
Git in dbt Cloud: a practical refresher
Before you write your first dbt model, here's the minimum Git knowledge you need - and exactly where to find it in dbt Cloud.
What is Git?
Git is a version control system - it keeps a full history of every change made to your code, who made it, and when. Think of it like tracked changes in Google Docs, but for SQL files.
In dbt Cloud, Git is built right in. You don't need to install anything or open a terminal. Every time you save and commit your work, dbt Cloud handles the Git operations for you behind the scenes.
Full history
Every change is recorded. You can always see what changed, when, and why - and roll back if something goes wrong.
Team collaboration
Multiple people can work on the same project simultaneously without overwriting each other's work.
What is a branch?
Every dbt Cloud project is connected to a Git repository - a shared store of all your SQL models, tests, and docs. A branch is your personal copy of that repository where you can make changes without affecting anyone else.
Your personal branch
Where you build. Create one branch per piece of work - a new model, a bug fix, a refactor. Your changes stay here until you're ready to share.
The main branch
The source of truth. Your production dbt jobs run from main. Nobody edits it directly - changes arrive only after review and approval.
How it looks visually
main ●────────────────────────────────● ← production runs here your branch ●──●──●──● ← you work here create edit edit
You branch off main, do your work, then eventually merge back in. Production is never touched while you're working.
Creating a branch in dbt Cloud
- 1In the dbt Cloud IDE, click the branch name in the top navigation bar (it shows
mainby default). - 2Click Create branch and give it a descriptive name. Use the format
feature/what-youre-building- for example,feature/add-stg-orders. - 3The top bar updates to show your new branch name. You're now working in your own isolated copy.
feature/stg-customers-dedupe is clearer than my-branch or fix1. Your teammates will thank you at review time.
firstinitiallastname (e.g. jsmith for Jane Smith). Always make sure you're on your personal branch before you start editing.
Commit and sync
Once you've written or edited a model, dbt Cloud needs you to do two things: commit (save a snapshot of your changes) and sync (upload that snapshot so the team can see it). In dbt Cloud, both happen with one button.
Commit
A named snapshot of your changes at a point in time. Like a save point in a game - you can always go back to it.
Sync
Uploads your commit to GitHub/GitLab so your instructor and teammates can see your work.
In dbt Cloud, you never type git commit or git push. Instead, look for the Commit and sync button - it does both in one click.
- 1After editing or creating a file, the Commit and sync button becomes active in the top bar.
- 2Click it. A dialog appears listing the files you changed. Review them - make sure nothing unexpected is included.
- 3Write a commit message that describes what changed and why. Then click Commit and sync to confirm.
What makes a good commit message
- ✓Be specific:
add stg_orders with order_date filterbeatschangesorwip - ✓Use present tense:
fix null handling in revenue model, notfixed - ✓One thing per commit: if your message needs "and" more than once, consider splitting it into two commits
