Cheat sheet, 4 min read, updated 30 September 2026

Git cheat sheet for data people

The Git commands data teams actually use, on one printable page.

GitAnalytics engineering
All cheat sheets and guides
All guides and cheat sheets

Setup

Terminal
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

Start

Terminal
git init                         # new repository
git clone https://github.com/org/repo.git

Everyday

Terminal
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' work

Branches

Terminal
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-model

Inspect history

Terminal
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

Terminal
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 commit

Stash

Terminal
git stash push -m "wip"
git stash list
git stash pop

Ignore files

A .gitignore for a Python and dbt project.

Text
.venv/
__pycache__/
.env
target/
dbt_packages/
logs/
*.xlsx

A simple team workflow

Terminal
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, merge

Never 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.