Version Control with Git in FTC Android Studio Projects

intermediate55 min

What is Version Control?

Version control records changes to your code over time. You can save snapshots, work with teammates without overwriting each other, and roll back when something breaks.

Installing Git and GitHub Desktop

Install Git for the command line. GitHub Desktop is optional but gives a graphical view of the same operations.

Downloading and Installing Git

Download Git: Git Official Downloads

Installation Guide: Git Installation Documentation

Use the installer defaults unless your mentor specifies otherwise. After install, open a terminal and run git --version to confirm it works.

Installing GitHub Desktop (Optional)

Download GitHub Desktop: GitHub Desktop Official Site

Getting Started Guide: GitHub Desktop Documentation

Sign in with your GitHub account after install so you can open team repositories.

Setting Up Your GitHub Account

Create an account at GitHub - Sign Up. Many FTC teams use a shared organization so every member can reach the robot repo and past seasons stay archived. See GitHub: creating an organization.

Why Use Git?

Git is the standard tool for sharing code, reviewing changes, and merging work from multiple programmers. For FTC, a team org on GitHub keeps one canonical robot project instead of copies on different laptops.

Basic Git Workflow

Typical flow: clone the remote repo, edit locally, stage changes, commit, then push. Pull before you push so you have teammates’ latest commits.

Cloning a Repository

Download a copy of a remote repository to your computer.

git clone https://github.com/your-team/ftc-robot-code.git

Adding and Committing Changes

Stage your changes and save them to the repository history.

git add .
git commit -m "Describe your changes"

Pushing and Pulling

Upload your commits to GitHub and download new changes from teammates.

git push
git pull

Branching and Merging

Branches let you work on a feature or fix without changing main until it is ready. Merging combines one branch into another.

Learn more: Git Branch Guide

Creating and Switching Branches

Create a new branch and switch to it.

git branch new-feature
git checkout new-feature

Merging Branches

Combine changes from one branch into another.

git checkout main
git merge new-feature

Resolving Merge Conflicts

If two people edit the same lines, Git marks a merge conflict in the file. Open the file, choose which changes to keep (or combine them), remove the conflict markers, then commit the result.

Learn more: Git Merge Guide

Best Practices for FTC Teams

  • Commit often with clear messages.

  • Use branches for new features.

  • Pull before you push to avoid conflicts.

  • Never commit sensitive information.

  • Review code before merging.

Practice Exercise

Try the basic Git workflow on your FTC project.

  • Clone your team’s repository.
  • Create a new branch and make a small change.
  • Commit and push your change.
  • Open a pull request on GitHub.