You are signed in. Close

You are signed out. Close

Thank you. Your subscription has started. Close

Thank you. You will get an email when a new comic comes out. Close

We could not confirm your payment. If you paid, use the link "Sign in" at the bottom of the page. Close

Something went wrong on our side. Please try again in a moment. Close

How Git keeps every version of your project without filling your disk

Git: why copying your project folder is not enough

final, final-2, final-really: copying a project folder feels safe until the day you need yesterday's version back. Why the copies fail, and what Git does instead.

  1. 1 You and your friend Rono are building a small web game, where a frog crosses a river by jumping from log to log.youRonothe frog game

    You and your friend Rono are building a small web game, where a frog crosses a river by jumping from log to log.

  2. 2 Miva, a friend, plays every new version. Today she finds a bug, and you want back yesterday's version, the one that worked.MivaThe frog fallsthrough the logs!

    Miva, a friend, plays every new version. Today she finds a bug, and you want back yesterday's version, the one that worked.

  3. 3 Each time something worked, you copied the whole project folder. There are four copies now, and no name says which one is yesterday's.frog-gamefrog-game-finalfrog-game-final-2frog-game-ronoyouWhich oneis yesterday?

    Each time something worked, you copied the whole project folder. There are four copies now, and no name says which one is yesterday's.

  4. 4 It gets worse. Rono added more logs to the river in his copy while you fixed the score in yours, and to get both into one game, someone has to compare every file by hand.your copyscore fixRono's copymore logsone game?Rono

    It gets worse. Rono added more logs to the river in his copy while you fixed the score in yours, and to get both into one game, someone has to compare every file by hand.

  5. 5 Keeping track of versions is called version control, and Git is the program most developers use for it. You keep one folder, and inside it Git keeps a hidden store, the repository, with every version you saved, who saved it and when.Gitfrog-gamerepository (hidden)youMonRonoTueyouWed

    Keeping track of versions is called version control, and Git is the program most developers use for it. You keep one folder, and inside it Git keeps a hidden store, the repository, with every version you saved, who saved it and when.

  6. 6 Your folder shows one version at a time, and any other one, like yesterday's that worked, can come back from the repository. Next: what Git really keeps each time you save.frog-gamewhat you seerepositoryMonTueWedcomes back

    Your folder shows one version at a time, and any other one, like yesterday's that worked, can come back from the repository. Next: what Git really keeps each time you save.

  7. Go further

    The real names behind the folder..gitthe real name of thehidden folder: therepository lives thereworking treethe files you see andchange: the oneversion on showLinus Torvaldsstarted Git in 2005,for the thousands ofpeople building Linux

    The real names behind the folder.

Next episode Git commit: how a snapshot of the whole project takes so little space

Share this comic

More comics