Space Git

Today one of my students wanted some help understanding how to solve a problem with git. I often find that students get stuck on the proper use of git's rebase, merge, pull, and fetch. They want to share and use commits from other repos, but can't quite get the commands to do what they need.

I've found the best way to deal with this is to get below the commands, and try to help people understand what git really is: a distributed filesystem. Even that can be hard, so today I tried a different tact in order to explain things. In case it helps you, I reproduce it here. Git is like a spaceship...

Photo by Gabriel Garcia Marengo on Unsplash

You're in a spaceship, traveling the galaxy, discovering and mapping its stars as you go. You're trying to establish the position of every star using a universal co-ordinate system--you want others to be able to return to each star if they so choose. You're not alone. There are other similar spaceships doing the same thing elsewhere in the galaxy, mapping stars, building a great star chart together.

In fact our project is to try and build as complete a star chart as possible, and no one ship can do it alone, since there is literally too much space to cover. It's a perfect task to be broken down, shared out amongst a willing group of explorers, distributed.

Photo by Kiwihug on Unsplash

We've each agreed upon different headings to take, and are now deep into our journeys. The map is emerging, slowly, and in pieces. On any given ship, a unique portion of the total map is taking shape, puzzle pieces on a table with large holes in between.

Love Puzzle Time Longing Wait Missing Expectation

No one has the whole map. Strictly speaking, there is no whole, only segments held in trust, in spaceships scattered throughout the galaxy. But every so often, we meet up with another ship. Sometimes at length while resupplying in a space port; other times briefly as we pass within communication distance. Whenever we do, we try to share our maps, connecting what we've found with what they've found, and also with all the other pieces they have from still other ships they've met deep in space.

You're in a spaceship, discovering stars, committing them to your local copy of the map, your repo. The information for each star is unique, and you record it, using SHAs so your numbering won't conflict with any other ship's.

When you meet another ship, you fetch the portions of the map that they have but you don't. The commits and their unique SHAs get added to your map. It's as if you've been there, too, and you won't need to go there in order to have that info. The other ship does the same, and now you both have identical, synchronized maps. They won't stay this way for long, since you'll both go in different directions and add more.

You're one of many spaceships charting the stars, sometimes lost in space for weeks or months at a time. While you will probably never all get back together, whenever you happen to meet another ship, you share what you've found with one another, and extend each other's map with the portion you've found.

You're lost in space. git reset --hard.