Git Add, Git Commit, and Git Log Basics
Introduction
Welcome to this lesson on Git Add, Git Commit, and Git Log Basics. In this lesson, you will learn how to manage changes efficiently in Git by understanding how your work moves through Git’s workflow—from your initial workspace to the project's history. You’ll explore the three key stages: the working directory, the staging area, and the repository. You'll also learn how to use essential Git commands, including git add to stage your changes, git commit to save them in the project’s history, and git log to review the history of your commits. By the end of this lesson, you'll have the foundational knowledge to manage changes in your Git projects effectively.
Understanding Git’s Workflow
In Git’s workflow, managing changes efficiently involves understanding how your work moves from being just an idea on your screen to being safely stored in your project history. This journey happens in three key stages:
-
Working Directory: This is where your active files live. Any time you edit a file, add new ones, or remove others, it happens here. Think of it as your workspace, where all the initial work takes place.
-
Staging Area (Index): Before saving your work permanently, you have a chance to review and decide which changes should be kept. The staging area serves as a middle ground, where you can prepare and review changes. You can think of it as a waiting room for the changes you want to keep, while others can stay in the working directory until you’re ready to include them.
-
Repository (Commit History): Once you’ve decided which changes to keep, you move them to the repository. The repository is where all your project’s progress is permanently recorded. Every time you save a snapshot of your project, it gets stored here, along with a history of everything that’s happened.
Revisiting the Example
Now that you have a sense of the workflow—how changes move from your workspace (the working directory), to the waiting room (the staging area), and finally to the project’s memory (the repository)—let’s revisit the example from our first lesson: Bob and Alice preparing for a surprise party.
Bob and Alice are collaborating on organizing a party, where they need to handle tasks like creating a guest list, planning the menu, and setting up decorations. Each task involves multiple revisions and contributions, making Git's workflow an ideal tool to manage these changes smoothly.
Using this example, we will understand how this flow works in action.
