What is Git?

By Tech Elevator Instructor Walt Impellicceiri

Git is a version control system. A version control system enables you to version files and folders. Put another way, it maintains a history of changes to files.

This is valuable because in software development, our work often involves making incremental changes over time. We may also be collaborating with other developers on these changes. Keeping track of these changes enables us the flexibility to change direction before we’ve gone too far down one path.

When using Git, the set of files and folders that are being tracked are in what is called a repository. A change to the repository is not permanent until it is committed. Think of it like painting a wall. You may paint numerous sample colors before committing to painting the entire wall. Similarly with Git, you can make many small changes before you are satisfied and mark the set of changes with a commit.

2 key benefits of using version control:

  1. The ability to undo a change. Perhaps you made a mistake and you’d like to erase your changes or you’ve recognized that another developer made a mistake and you’d like to reverse their changes. This is done by making a change that is the reverse of previous.Again, think of it like painting a wall. You may have started with a wall that was blue, then you painted it gray, but decided later that you did not like the gray color and preferred the blue color. You wouldn’t try to remove the gray color to uncover the blue color. Rather, you would repaint the wall blue.
  2. The ability to see how you got to where you are. Let’s say you are collaborating with others on a project and you’re wondering why a certain change was made or why code was written in the way that you see it. Git can allow you to see the history of a file, including who has made changes, what the changes were, and even why they made them.

Think of this like a CarFax history report for a car that you are considering purchasing. The car may look great in its current state, but it’s still valuable to understand where that car has been and the work has been done to it in order to get it to its current state.

Collaborate using version control:

Software is often built by teams of people. Git can be used to foster collaboration amongst teams. Think of a shared Git repository like a shared photo album on your mobile device or a DropBox folder that you share with others. When photos or files are added or removed to the album or folder, other users automatically see those changes. That’s quite similar to how a shared Git repository works. The only caveat is that with a shared Git repository, the changes are not automatically pushed to the cloud and pulled onto others’ devices – this process is intentionally manual to ensure that folks that are working on the same files can choose when and how to merge their changes together.

One of the best examples of version control that I’ve seen is Wikipedia. It enables a collaborative approach to building up a repository of information. It’s quite similar to how a team would work on a software project using Git. Git and similar version control systems have even been used to track changes to legislation. Can you think of other examples where versioning things may be useful?

Good luck on your coding journey. If I can help with anything along the way, feel free to drop a comment below. 

Walt Impellicceiri

Walt InstructorWalt graduated from the University of Pittsburgh with a degree in Computer Engineering. He has spent the last 10+ years developing applications for companies in the healthcare, retail and education industries. He leads instruction at Tech Elevator Pittsburgh.