Here's what version control is and why you need it.
Tags: beginners
Published: 2022-10-16 17:34:01

Imagine that it’s the year 1998 and you’re a 3D animator working on a multi-million dollar movie with strict deadlines and a tight budget. You need to make a fix to a character’s hat, so you take a look at the directory containing the character’s files. You’re not exactly sure why, but the files start to vanish. Like a plague, the vanishing spreads into other directories too. Hundreds of hours of work is disappearing right in front of you.

Oh sh*t.

This is actually what happened to Pixar during the development of Toy Story 2. Someone likely ran the command rm -rf * in the root directory, which deletes everything in the directories below it — thus starting the deletion of literally every file that encompassed Toy Story 2.

It took hundreds of hours of manual effort and tears to recover these files. In the end, they ended up canning the first iteration of Toy Story 2 anyway because it wasn’t up to Pixar’s standards — but the event still taught Pixar to make sure they took consistent, properly working backups .

Let’s fast forward to today. Traumatic file-deletion catastrophes can now be prevented by a little something called Version Control. Specifically, distributed version control, but more on that later.

The authors of the book “Pro Git” describe it best, version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. Why is this helpful? Having a version control system in place for your files makes it really, really easy to see exactly what changes you made when — and to rollback those changes when you need to.

For example, have you ever worked on a group project where you were emailing different versions of a file back and forth? Or maybe you wrote a couple of lines of code that completely broke the program you were working on, and now you have to struggle to remember what lines you modified.

Version control helps to fix these issues. In the case of that group project, version control makes it so that you don’t have to keep track of who made what changes — the version control system would take care of it for you. You also wouldn’t have to keep emailing files back and forth, especially with distributed version control — everyone would have their own copy of the file they would work on, and then simply push those changes to a remote, centralized repository that also contains a copy of those files.


![Source: pro-git book](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpv3slcbgdcbxe7escht.png)

When you’re writing code, using a version control system helps you rollback those program-breaking changes so you can quickly get your program functional again.

In the case of Pixar, using a distributed version control system would have saved the heartache of having to spend hundreds of hours recovering deleted files — because everyone would have had local copies of the movie files — so who cares if someone accidentally deletes their copy of the files on their workstation?

Today, there are many version control systems out there, but the most common one I’ve seen is Git. If you’re interested in learning more about using Git — I’ve included some resources below.

Resources:

https://git-scm.com/book/en/v2

https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/

https://rogerdudler.github.io/git-guide/