Overview of Git and GitHub
Git and GitHub are foundational to effective teamwork and collaboration. The following material provides some additional information and insight into these tools.
We'll use a methodology called one-in-three, explaining one concept in three ways—with each section getting progressively more technical. While this approach might seem redundant, it's a great way to gain a broad understanding of a new field or concept!
Let's begin by learning how we can use Git for version control. Understanding the basics of Git enables developers to collaborate with colleagues and communicate effectively across technical teams.
This high-level overview will introduce you to common vocabulary and concepts relevant to the technology.
Part 1: Quick Introduction
Git and GitHub are tools that help people collaborate and safely store their code.
Developers need a place to safely store their code. Imagine that you kept all your projects on your computer, and your computer was stolen—you could lose months of work! Just like you can use Dropbox to back up documents, GitHub is an online space to store code. GitHub also allows you to share code with other people and work together on projects.
Git is a software application that runs on your machine and allows you to add to and download from GitHub.
Part 2: The Bigger Picture
What Is Git?
Git is a version control software that runs on your computer. It serves two primary purposes:
-
It tracks changes to any files in your project. If you have a working application and you accidentally break it, you can roll it back to a previous point. Unlike Microsoft Word or similar programs, not only can you return to the previously saved version, but you can return to any point in time that you saved.
-
It allows you to add (push) and download (pull) code from your online code repository on GitHub, similar to the Dropbox client that syncs your local files.
Real-World Example
Imagine playing a video game with a key that you can press to save at any time you want. Perhaps you saved twice in the first level, once in the second level, and once in the third level. The game is going well, but suddenly it takes a turn for the worst. Your health is waning, your energy is low, and you're down to your last life. Not to worry—you can go back to any of your save points!
The save point from the third level seems like the obvious choice because you were the furthest along in the game at that point. You pop back to the saved version in the third level, and your game is just as you left it! Health is great, energy is high, and you have lives to spare. But before too long, you end up in the same predicament.
You realize that the bad decisions that led to your problems actually occurred much earlier than you thought. So you pop back to your second saved version on the first level and whiz through the game with ease!
This video game scenario happens frequently in software development. For example, suppose that you're building event management software for a local event planner who asks you to add a calendar widget. After making good progress for a few days, you code yourself into a corner and break the entire application trying to figure it out. Not to worry! If you used Git and saved (pushed) frequently enough, you can roll back to exactly the point where you took a wrong turn.
What Is GitHub?
GitHub is a web-based storage solution for developers. It's like Dropbox or Google Drive; you can store code for safekeeping and share it with others. But it's also a version control system!
Suppose that you're managing a team of five developers and they are all working on a project. Quality is dropping, and more bugs are slipping into production. GitHub can tell you who wrote the offending files, as well as who reviewed them and said they were okay. If you want to roll back to a previous version when things were more stable, you can do that!
GitHub also helps developers collaborate. Let's consider a real-world example of how it does that.
Real-World Example
Janet and Tasha are working together on a login feature, and they aren't using GitHub. The design files call for two shades of green and a shade of yellow to be used on the site. Janet is working on the login box and adds a green background; meanwhile, Tasha is working on the same feature and adds a purple background. Janet uploads her files first, followed closely by Tasha—so the background ends up purple. This is definitely not right, but without GitHub, whoever pushes last wins!
Let's consider the same scenario with GitHub.
Janet pushes her code, and it's merged into the production code. Tasha pushes her code, but GitHub blocks it from being merged. There's a conflict! Someone on the team has to review the code, check the conflict, and choose which code is correct. Their teammate Alysha reviews the code, notices that the purple doesn't match the design files, and tells GitHub to use the green background before merging the rest of Tasha's code.
And there you have it—cloud storage, version control, and source code management all in one!
Part 3: Detailed Technical Explanation
What Is Git?
Git is the most widely used version control system. Version control software helps a team manage changes to its source code. Git was created originally in 2005 to manage the Linux kernel; nowadays it is used worldwide for countless software projects.
Git tracks your changes to the source code via commits. It syncs with a remote source, like GitHub or Bitbucket, via push (to send your commits to the remote) and pull (to retrieve commits from the remote) commands.
What Is GitHub?
GitHub is an online space to work collaboratively on projects and keep your code safe.
Most software development teams need to work simultaneously. GitHub allows us to do that safely. It is a powerful tool that all developers rely on heavily!
Virtually every software company stores its code in GitHub or a similar service.