Branches let you experiment without breaking main.

  1. Create and switch to a branch
  • git branch feature/readme-update
  • git switch feature/readme-update # or: git checkout feature/readme-update
  1. Make a change and commit
  • echo “More details” >> readme.txt
  • git add readme.txt
  • git commit -m “Expand readme”
  1. Switch back and merge
  • git switch main # or: git checkout main
  • git merge feature/readme-update
  1. Optional: create a conflict
  • On main: change first line of readme.txt and commit
  • On a new branch: change the same line differently and commit
  • Merge into main and resolve conflicts in your editor, then:
    • git add readme.txt
    • git commit # completes the merge

Checklist

  • New branch created and switched
  • Changes merged into main
  • You can resolve a simple conflict