• 12 hours
  • Easy

Free online content available in this course.



Got it!

Last updated on 8/21/19

Dive into Git's superpowered advantage: version control

Log in or subscribe for free to enjoy all this course has to offer!

Now you’re ready to dive into Git and GitHub. But what’s the difference between them? To start, we’ll examine the first of these: Git. The Git system provides a powerful tool: version control. Let’s check out how it works!

What is version control?

Have you ever spent days coding, made real progress changing things around only to have something break? 😱 It was perfect one minute, and then a teeny tiny change broke the whole thing. But which change? How do you find it? How far do you backtrack changes? Does this mean you have to rewrite your code? 😭 If only you could roll back to a previous version, or find out what change set it off!

Yikes!  I screwed up my code!
Yikes! We've all been there! 

Well, don’t worry too much - mistakes like these are common!  Developers are constantly working on different versions of code, switching things up, or having to backtrack when bugs happen!  Wouldn’t it be great to have a system that keeps track of all these changes? Wouldn’t it be useful if you could automatically save previous versions in an archive, just in case you need them again?   Lucky for you, there is an awesome solution that does both of these things: version control. 🌟 And you can use version control via a handy software application called Git!

The Git Version Control System
The Git version control system

You’re probably already familiar with version control in your everyday life.  Think about the textbooks you used in school. A lot of them were written a long time ago, but have been revised several times.  For example, you may have had a 10th edition math book! That means that the 10th edition is the latest version, and to stay up to date, it contains significant changes.  With each change, an expert added, deleted, or changed existing content before submitting it to an editor. That's not very different from a typical code project - except you submit it to your fellow developers for review.

Once the changes were approved, new content was integrated to create a new version. The older versions still exist, though. For example, if the publishing company gets feedback that teachers preferred the older version of a chapter, they can revert back to this in a new version of the textbook.

I'm pretty sure these books have newer versions
I'm pretty sure these books have newer versions

Well, you can do the same thing with your code using the Git version control system! 😀 Even more so than textbooks, web applications and software constantly evolve.  They may get additional features, need changes due to bugs or problems, or require small feature updates. To handle these situations, version control allows you to archive all versions of your source code and stay organized. With Git, you can: 

  • Follow the progression of changes to an entire code project, step by step.

  • Track individual changes, when they were made, and by whom.

  • Roll back to a previous version because all versions on your project are archived with Git! 

All of this enables you to manage your code projects more effectively.

Versioning in team projects

You’ve seen how version control can help you, the individual, organize your code, but Git’s real power is in how it facilitates teamwork. And the truth is that in the real world, on company code projects, you’ll very rarely code alone!

Version control systems fix one big problem: if you only have one master document in a team, you can only really work on it one at a time. It would be like having only one word processing document on a team project.  Now you could all work together on one computer, but that's won't work for a team with more than two people.

Many people.  One computer.
Many people. One computer. Not optimal.

Even if each person made a copy to work on at home, imagine how confusing it would be to have to put all the changes back together - especially if they contradict one another. You could require people to reserve time on the document and constantly communicate, but that's a recipe for a headache.

Git's version control system allows teammates to work on their own version of the document, then integrate the changes seamlessly into the main version.

Versions on multiple machines
Versions on multiple machines

So, it's a file sharing system, like Google Docs, right?

Not quite! In Google Docs, everyone makes changes to one master document in real time.  With Git's version control, changes you make on your own computer are saved individually.  Unlike a separate word processing document, you can send your changes back to a master document when you're ready. And you don't write over what is in the master document.  Your teammates check your changes and then integrate them into the master document once they approve them. 

Once approved, only the changed sections will be integration
Once approved, only the changed sections will be integrated

That means more than one person can make continuous changes.  For example:

  • You can make some changes to parts of a program and save it.

  • Your teammate can work on other parts of the same program and save it.

  • In the end, the program will have your code, and your teammates' code saved on it.

This has several advantages:

  • Developers can work independently on their own versions of the main document, then share code when they are ready. 

  • Developers can save alternate versions without having to integrate it into the main code. This is especially useful when working on a new or alternative feature.

Version control: a facilitator of open source projects

You may have seen open source projects on the web. Contributors with varying skill sets from around the world participate in writing code! In fact, a lot of them are important software projects currently in production.

So, how can they allow so many people from all over the world, indiscriminately contribute to their projects on Github and not end up with a complete mess? As you saw before, the version control system with Git allows you to copy any code project to your computer, work on it, then send your changes back up to Github with no hassle at all!

Contributors submit changes as suggestions.  When contributors help resolve issues or add features to code, they provide their own version of the code. The project owners determine whether or not they would like to use these suggestions to create a new version!  It’s not a big deal if they don’t, because it's still saved and can be used later. That way, there are no wasted efforts!

Okay! Enough about version control.  In the next chapter, we'll look at version control’s backbone, code repositories! 🙃

Let’s recap!

  • Git is a decentralized version control system that allows different versions to exist separately.

  • Version control allows you to track and manage different versions of source code. 

  • Version control facilitates team and open source projects. 

Example of certificate of achievement
Example of certificate of achievement