Setup
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch mainStart
git init # new repository
git clone https://github.com/org/repo.gitEveryday
git status # what changed?
git add models/fct_orders.sql # stage one file
git add -p # stage piece by piece
git commit -m "Add fct_orders model"
git push
git pull --rebase # get teammates' workBranches
git switch -c feature/orders-model # create and move
git switch main
git branch -d feature/orders-model # delete merged branch
git merge feature/orders-modelInspect history
git log --oneline --graph --all
git diff # unstaged changes
git diff --staged # staged changes
git blame models/dim_customers.sql
git show <commit>Undo safely
git restore file.sql # discard local edits
git restore --staged file.sql # unstage
git commit --amend # fix last commit message
git revert <commit> # undo a pushed commit
git reset --soft HEAD~1 # undo last local commitStash
git stash push -m "wip"
git stash list
git stash popIgnore files
A .gitignore for a Python and dbt project.
.venv/
__pycache__/
.env
target/
dbt_packages/
logs/
*.xlsxA simple team workflow
git switch main && git pull
git switch -c fix/revenue-definition
# ...edit, then:
git add -p && git commit -m "Exclude refunds from revenue"
git push -u origin fix/revenue-definition
# open a pull request, let CI run dbt build, get a review, mergeNever commit secrets
Keep passwords and API keys in environment variables or a .env file listed in .gitignore. If a secret is ever committed, rotate it immediately: deleting the file does not remove it from history.
Written by Alessandro Ecclesie Agazzi, freelance analytics engineer in London. Updated 30 September 2026.