MarMic-Git-Workshop-2024

Git Basics

Version control is a fundamental concept in software development. It helps you manage changes to your codebase efficiently, collaborate with others, and track the history of your project. In this chapter, we’ll cover the key aspects of version control in the context of Git.

Git Terminology

Git introduces several essential terms that you need to grasp to work effectively with it:

The Three Main Stages of Git

Git operates in three primary working areas, each serving a unique purpose:

By understanding the different working areas in Git, you’ll have a better understanding of how Git tracks changes and how the basic commands operate.

flowchart LR
 wd[Working Directory] 
 --`git add`--> 
 sa[Staging Area] 
 --`git commit`--> 
 re[Repository]
 --`git push`--> 
 rr[Remote Repository]
 --`git pull`--> wd

 style wd fill:#ccc,stroke:#666,color:#333
 style sa fill:#ccc,stroke:#666,color:#333
 style re fill:#ccc,stroke:#666,color:#333
 style rr fill:#ccc,stroke:#666,color:#333

What is a Commit

A commit is a crucial concept in Git that captures the state of your project’s files at a specific point in time. It plays a vital role in version control by recording changes, authorship details, and commit messages. Here’s a more structured presentation:

gitGraph
 commit id:"A"
 commit id:"B"
 commit id:"C"

What is a Branch

Branches are essential for parallel development and managing changes to your codebase without affecting the main version. Here’s an improved version of this section:

gitGraph
 commit id:"A"
 branch feature-x
 checkout feature-x
 commit id:"B"
 checkout main
 merge feature-x