Robotics software is written by multiple students and mentors under intense competition deadlines. Without version control, code gets accidentally overwritten, untracked changes cause erratic field behavior, and reverting breaking changes becomes impossible.
This lesson establishes standard Git practices for FRC software development.
1. Team Repository Structure
Section titled “1. Team Repository Structure”A standard WPILib Java repository is organized into specific directories managed by the Gradle build system:
robot-project/├── .gitignore # Files excluded from version control├── build.gradle # Gradle dependencies and WPILib plugins├── gradlew, gradlew.bat # Gradle wrapper scripts for Unix and Windows├── vendordeps/ # JSON manifests for CTRE, REV, PathPlanner└── src/ └── main/ ├── deploy/ # Non-code assets pushed to roboRIO (paths, configs) └── java/ └── frc/ └── robot/ ├── Main.java # Program entry point (do not edit) ├── Robot.java # Low-level loop cycles ├── RobotContainer.java # Subsystems and controller bindings ├── Constants.java # CAN IDs, gear ratios, PID gains ├── commands/ # Command classes and autonomous logic └── subsystems/ # Hardware subsystem wrappers2. Essential .gitignore Rules
Section titled “2. Essential .gitignore Rules”Robotics projects generate large build artifacts and multi-megabyte telemetry logs. Committing binary build files bloats repository history and causes merge conflicts between team members.
Verify that your .gitignore includes the following patterns:
# Gradle build outputsbuild/.gradle/bin/
# IDE files.idea/*.iml.vscode/*!.vscode/settings.json!.vscode/tasks.json!.vscode/extensions.json
# AdvantageScope and WPILib data logs*.wpilog*.dlog
# OS metadata.DS_StoreThumbs.dbAdvantageScope and WPILib DataLog generate .wpilog binary files that can easily exceed 50 MB per match. Committing these files quickly exceeds GitHub repository limits and slows down git clone operations for all team members.
3. Student Branching Workflow
Section titled “3. Student Branching Workflow”Follow a trunk-based or feature-branch model:
- Keep
maindeployable: Code on themainbranch must always compile and run safely on the physical robot without crashing. - Create short-lived feature branches: Before writing a new mechanism subsystem or autonomous routine, branch off
main:Terminal window git checkout maingit pull origin maingit checkout -b feat/intake-subsystem - Commit with intention: Make small, frequent commits with clear messages:
Terminal window git commit -m "Configure intake Talon FX stator current limit to 40A" - Open a Pull Request: Submit a PR to
mainand have a peer student or mentor review your changes before deploying to the physical robot.
Common Failure Modes
Section titled “Common Failure Modes”1. Merge Conflicts in vendordeps/*.json
Section titled “1. Merge Conflicts in vendordeps/*.json”- Symptom: Git blocks a merge due to conflicts in a vendor JSON file.
- Cause: Two team members installed or upgraded vendor libraries on different branches.
- Fix: Re-run
WPILib: Manage Vendor Librariesfrom the Command Palette onmainto regenerate a clean JSON, or accept the latest version block manually.
2. Committed Build Folder
Section titled “2. Committed Build Folder”- Symptom:
git statuslists hundreds of.classfiles inbuild/. - Cause: Project was initialized before creating
.gitignore. - Fix: Run
git rm -r --cached build/and commit the updated.gitignore.
Check Your Work
Section titled “Check Your Work”- Clone your team repository to your workstation:
Terminal window git clone <repository-url>cd <repository-directory> - Build the project using the Gradle wrapper:
- On Windows:
.\gradlew.bat build - On macOS/Linux:
./gradlew build
- On Windows:
- Verify that
git statusreports a clean working tree:On branch mainnothing to commit, working tree clean
Verified Sources & Standards
- WPILib Source Code Repository Management Guidedocs.wpilib.orgWPILib Standard