Key concepts

Git

Git is a version control system that developers use to track and manage changes to software projects.

Imagine you're writing a story and, over time, you make various edits—deleting some parts, adding new ones, or completely revising entire chapters. Now, if you want to remember or restore a previous version of your story, you'd need a detailed record of all the changes.

That's essentially what Git does for software development: it keeps a comprehensive history of every modification made to the code.

At the heart of Git's functionality is the repository. Think of a repository as a project's directory, which not only contains the current version of all the project files but also an extensive log of every change made to them since the repository was initialized. As developers make changes to the codebase, Git keeps a record of these changes in its history. This allows developers to revert to previous versions of the code if needed, compare changes between different versions, and collaborate with others on the same project.

Git solves the problem of managing changes to a codebase over time, especially when multiple developers are working on the same project. Without a version control system like Git, it would be difficult to keep track of who made what changes and when, leading to conflicts and lost work. Git helps to prevent these issues by providing a clear history of changes and allowing developers to work on separate branches of the codebase.

Git was developed in 2005 by Linus Torvalds, the Finnish-born software engineer best known for creating the Linux kernel. Since then, it has become an essential tool in modern software development, especially in the open-source community. Platforms like GitHub, GitLab, and Bitbucket have built entire ecosystems around Git, providing tools for collaboration, continuous integration, and deployment.

Git interfaces

Main entry: Git CLI vs. GUI

While Git is primarily a command-line tool, there are also many graphical interfaces available that provide a more user-friendly way to interact with Git. These tools can be particularly helpful for developers who are new to Git or who prefer a visual interface. Many popular IDEs, such as Visual Studio Code and IntelliJ IDEA, have built-in support for Git, making it easy to use within the development environment.

Git in macOS Terminal
Git in macOS Terminal
Git in VS Code user interface
Git in VS Code user interface

Version control in normal software vs. Git

Many non-coding tools such as Google Docs, Microsoft Word, or Dropbox have some form of version history. But they don't work like Git. Traditional version control systems track changes to each file independently of changes to other files.

For example, imagine I have written a book in Google Docs, where each chapter is a separate document. The book is almost finished, and in a few days I'm sending it to the publisher.

In the evening, after having too much wine, I decide to introduce a new plot line super quickly. I change multiple chapters, add a few paragraphs here and there. Morning comes, and I realize that the whole idea was a total mess, and I want to undo it.

Luckily, Google Docs has document history, which lets me revert the document to a previous version. But I have to visit each and every changed document and revert its changes. If I accidentally miss one of the files... (nah, this won't ever happen).

Even though all those changes were part of one big update, they are completely separate in the history of each document.

Git tracks changes across the whole project and lets you create "snapshots" of the entire project state at a specific moment in time. If you had that book project in Git, you could make a commit that captures all the changes across all the chapters at once. If you later decide to undo that commit, Git would revert all the changes in one go, restoring the entire project to its previous state. This makes it much easier to manage complex changes that affect multiple files and ensures that your project's history remains coherent.