← All cheatsheets
Data Engineer · #042 · September 3, 2026 · 2 min read

Which git commands do data people actually need?

The daily loop, branches, the three ways to undo, how to read history, and the .gitignore hygiene that keeps 2 GB CSVs and API keys out of your public portfolio repos.

Get the free PDF

One page, print-ready, free to share. No signup needed.

Download the PDF

Every portfolio project lands in a repo, and recruiters read them. Here is git cut down to the part data work actually uses, plus the hygiene rules that keep CSVs and keys out of public history. The print-ready A4 PDF is at the bottom.

The daily loop

  • git status: what changed.
  • git add -p: stage chunk by chunk.
  • git commit -m "…": say why, not what. "fix tz bug", not "edits".
  • git push: ship it.

Branches

  • git switch -c fix-x: new branch, experiments live here.
  • git switch main: go back.
  • git merge fix-x: bring it in.

Undo

  • git restore f.sql: discard a local edit.
  • git revert <sha>: undo a commit, keep history.
  • git stash: park it, come back later.

Reading history

  • git log --oneline: the story so far.
  • git diff main: what would merge.
  • git blame f.py: who touched this line, and when.

Data hygiene

  • .gitignore first: before commit number one.
  • *.csv, data/, .env: never in a repo.
  • Commit the schema, not the rows.

The loop, in one block

git status              -- what changed
git add -p              -- stage hunk by hunk
git commit -m <why>     -- "fix tz bug", not "edits"
git push                -- ship it

git switch -c <branch>  -- experiments live here

add -p shows every change before staging it. It is also how you catch the file that should never be committed.

The trap: the repo is public

You committedWhat happensDo instead
data/raw.csv, 400 MBclone takes minutes, forever.gitignore + a sample
.env with an API keyscrapers find it in hoursrotate it, then clean
password in a notebookit stays in historynever in code at all

A portfolio repo gets read by recruiters. And by scrapers. Deleting a file in a new commit does not remove it from history: assume any pushed secret is burned, and git push --force rewrites history other people share.

Frequently asked questions

Which git commands do I actually need day to day?
Four cover 90% of real usage: git status to see what changed, git add -p to stage change by change, git commit -m with a message that says why, and git push to ship it. Add git switch -c for branches and you have the whole daily loop.
How do I undo a commit in git?
Depends what you want gone. git restore file discards a local edit you have not committed. git revert <sha> creates a new commit that undoes an old one, keeping history intact, which makes it safe on shared branches. git stash parks uncommitted work so you can come back to it.
Should I commit CSV files to a git repository?
No. Write the .gitignore before your first commit and put *.csv, data/ and .env in it. Commit the schema and a small sample, not the rows: a 400 MB CSV makes every clone take minutes forever, because git keeps it in history even after you delete the file.
I accidentally committed an API key to GitHub. What do I do?
Rotate the key first, immediately: scrapers find exposed keys in public repos within hours. Deleting the file in a new commit does not help, because the key stays in history. Once the key is dead you can clean the history, but assume any pushed secret is burned.

Get the free PDF

One page, print-ready, free to share. No signup needed.

Download the PDF

More cheatsheets