14 Gi Git

Element 14 of 86 — The Periodic Table of Robotics

Git

Code & Software

Track every change to your robot's code, roll back mistakes instantly, and collaborate with the world — Git is the essential safety net for any project.

git-scm.com

Every robot project grows. What starts as a single script turns into dozens of files, tweaks, experiments, and “I wonder what happens if I change this” moments. Git is how you keep track of all of it without losing your mind.

What is Git?

Git is a version control system — a tool that records a full history of every change you make to your project files. Each time you save a snapshot (called a commit), Git stores exactly what changed, when, and why. You can scroll back through that history at any time, compare two versions side by side, or restore a file you accidentally broke.

Git was created by Linus Torvalds in 2005 — the same person who wrote the Linux kernel — and it’s free, open source, and everywhere.

A few key ideas to know:

  • Repository (repo) — a folder whose entire history Git is tracking.
  • Commit — a saved snapshot with a short message describing what changed.
  • Branch — a separate line of development, so you can try things out without touching the main working code.

Commits and branches

Each commit is a snapshot linked to the one before it, forming a history you can walk back through. A branch lets you spin off an experiment without disturbing main; when it works, you merge it back in:

   main:   A───B───C─────────────F   ← merge back in
                    \           /
   feature:          D───E─────╯
                     (try a new sensor —
                      main stays safe)

   A,B,C,D,E,F = commits (snapshots)
   each arrow points to the commit before it

If the experiment on the feature branch goes wrong, you just delete the branch — main was never touched. That safety net is exactly why you commit early and often.

Why robot builders care

When you’re tuning a PID loop or rewriting your motor control code, things break. Without Git, a bad experiment can overwrite perfectly working code and you’re left guessing what you changed. With Git, you just run git checkout and the broken version disappears.

Git also means you can share your designs with the community. Almost every open-source robot platform — SMARS, ROS packages, MicroPython libraries — lives in a Git repository. Knowing Git means you can clone those projects, contribute fixes, and share your own builds with the world.

Get started

The best place to begin is the command line — on Raspberry Pi OS, Git is already installed.

The Introduction to the Linux Command Line on Raspberry Pi OS course on this site walks you through everything from basic terminal use up to Introduction to Git and Basic Git Commands — a natural progression that puts Git in context alongside the other tools you’ll use every day.

Here’s the mini-project that makes Git click: create a new folder for a robot project, run git init inside it, write a short Python script, then commit it with git commit -m "first working motor test". Change one line, commit again. Run git log to see your history, then git diff to see exactly what you changed. That two-minute exercise teaches you more about Git than any amount of reading.

Once you’re comfortable with local commits, create a free account on GitHub and push your repo there. Now your code is backed up and visible to the whole maker community — a big deal when you’ve spent a weekend building something cool.

A tidy Git history also makes debugging easier. If your robot worked two weeks ago and doesn’t now, git bisect can find the exact commit that broke it — a time machine for your code.

Reacts well with

More Code & Software

Learn more on KevsRobots

Articles to read

Share this element

This page is awesome? Show some love!

Did you find this content useful?


If you found this high quality content useful please consider supporting my work, so I can continue to create more content for you.

I give away all my content for free: Weekly video content on YouTube, 3d Printable designs, Programs and Code, Reviews and Project write-ups, but 98% of visitors don't give back, they simply read/watch, download and go. If everyone who reads or watches my content, who likes it, helps fund it just a little, my future would be more secure for years to come. A price of a cup of coffee is all I ask.

There are a couple of ways you can support my work financially:


If you can't afford to provide any financial support, you can also help me grow my influence by doing the following:


Thank you again for your support and helping me grow my hobby into a business I can sustain.
- Kevin McAleer

What are you looking for?
Watch Videos Get Ideas Learn Something Read a Review Read the Blog Search
... Z Z z