Unit 3: Version Control and Troubleshooting
Version control is a system that tracks every change you make to your code. It's an essential tool for collaborating with teammates, tracking down bugs, and safely experimenting with new features without breaking your project.
Imagine you're writing an essay. You might save different versions as you go: `Essay_draft1.doc`, `Essay_final.doc`, and `Essay_final_final_I_promise.doc`. Version control automates this process. It allows you to save "snapshots" of your project at any time and revert back to them if needed. The most popular version control system in the world is Git, and the most popular website for hosting Git projects is GitHub.
Understanding a few key terms is essential to using Git effectively.
The project folder. A repository contains all of your project's files and the entire history of changes.
A snapshot of your code at a specific moment in time. Each commit has a unique ID and a descriptive message.
A separate timeline of commits. This allows you to work on new features without affecting the stable, main version of your code.
The action of combining the changes from one branch into another, integrating new features into the main project.
A version of your repository hosted on the internet, like on GitHub. This is how you collaborate and back up your code.
The fundamental workflow for saving your work in Git involves a two-step process: adding changes to a "staging area" and then committing them with a message.
// 1. Initialize a repository in your project folder (only done once)
git init
// 2. Add a file to the staging area. This prepares it for the next commit.
git add src/main/java/frc/robot/Robot.java
// 3. Commit the staged changes with a descriptive message.
git commit -m "Initial commit: Add base Robot.java file"
// --- After making more changes to your files ---
// 4. Add your new changes to the staging area.
git add .
// 5. Commit the new snapshot.
git commit -m "Feat: Add basic motor control for intake"
On Jack in the Bot, we follow professional standards to ensure our codebase is clean, collaborative, and easy to maintain. Adhering to these rules is mandatory for all programmers.
Using Git and adhering to our team standards is non-negotiable for several key reasons:
Question: According to the 2910 standards, what is the most important reason for making small, frequent commits?