Branching and Merging

intermediate20 min

Branches

A branch is a separate line of history. You can build autonomous changes on one branch while main stays competition-ready.

Ideas

  • main (or master) — stable code you trust to run on the robot
  • Feature branches — one topic per branch (auto routine, teleop fix)
  • Merge — bring a branch’s commits into another branch
  • Conflict — two branches edited the same lines; you choose the result

Branch commands

git branch feature-name          # Create new branch
git checkout branch-name        # Switch to branch
git checkout -b new-branch     # Create and switch
git branch                      # List branches
git branch -d branch-name      # Delete branch

Merging

On the branch you want to update (often main):

git merge feature-name

Git may fast-forward if history is linear, or create a merge commit. If the same lines changed on both sides, Git marks conflicts in the file. Edit the file, remove conflict markers, git add, then commit.

Robotics branching examples

  • autonomous-improvements — auto routine work
  • teleop-enhancements — driver controls
  • fix-drivetrain-issue — targeted bugfix
  • Merge when tested; keep main deployable

Branch habits

Keep feature branches short and focused. Merge or delete them after integration so the branch list stays readable.

Further Reading Resources