DCubes
Git module

Lesson 6

Branches

Create and switch branches so features stay off main until ready.

beginner30 minRun on your machine

What you will be able to do

  • Create a branch with git branch / git switch
  • Make a commit on a feature branch
  • List branches

Why this matters for data work

main should stay releasable. Feature work (new SQL, job fix) happens on a branch, then merges after review.

Concepts

  • Branch — movable pointer to a commit
  • git switch -c feature/name — create and switch
  • git branch — list
  • git switch main — go back

Practice on your machine

cd ~/dcubes/git-lab/init-demo
git switch -c feature/add-sql-note
cat > notes.sql << 'EOF'
-- placeholder revenue check
SELECT 1;
EOF
git add notes.sql
git commit -m "Add placeholder notes.sql"
git branch
git log --oneline --graph --all | head

What you should see

  • feature/add-sql-note in branch list.
  • main without notes.sql until you merge (next lessons).
git switch main
ls

notes.sql should be gone on main.

Common mistakes

  • Working on main for everything — hard to review.
  • Detached HEAD from checking out raw commits — use branches for work.

Next

Merge basics