Miron Chen
Tutorial

Git 101 - Basics

Cover Image for Git 101 - Basics

1. What Is Git?

Before we start learning Git, we first need to understand what Git is and what it does.

Git is a Version Control System (VCS). It records how files change over time, allowing us to view previous versions, restore older versions, and collaborate with other people. Since this is the beginning of the tutorial, we will not cover collaboration yet. We will discuss it in later chapters.

1.1 What Is Version Control?

Suppose you are writing a program.

At the beginning, your project might be called:

project

After making some changes, you are worried that the new version might break, so you make a copy:

project_v2

After a while, you may end up with:

project
project_v2
project_final
project_final_v2
project_final_really_final

Although this approach appears to preserve previous versions, it quickly creates several problems:

  • You do not know exactly what changed between versions
  • More and more files are created, taking up unnecessary space
  • It becomes difficult to tell which version is the latest
  • When working with other people, files can easily overwrite each other
  • Restoring only one specific change becomes very inconvenient

Git was designed to solve these problems.

When using Git, we usually keep only one copy of the project files, while Git helps us record every important change.

For example:

Initial project
      ↓
Add login page
      ↓
Fix login bug
      ↓
Add user profile

Each of these points can be saved by Git.

If we later discover that:

Add user profile

introduced a serious problem, we can still inspect or restore an earlier version.

If you are not a professional developer but want to try vibe coding, learning how to use Git is especially important:

  • AI hallucinations may cause incorrect changes
  • You may accidentally modify something and later forget what changed
  • AI may make a large number of changes, but you may want to return to an earlier state

Although most modern agentic coding tools provide a one-click Undo feature, there is still no guarantee that every action will be free from unexpected side effects. Using Git properly may save you from an approaching deadline and a crashing program — or at least help you get it running again.

1.2 What Does Git Record?

Git mainly records changes made to a project.

For example, suppose a file originally contains:

Hello

Later, it is changed to:

Hello Git

Git can identify the difference:

-Hello
+Hello Git

In other words, Git does not simply save many copies of the same files. Instead, it helps us manage changes between different versions of a project.

These saved versions are usually called:

Commits

You can think of a commit as:

A save point for the current state of your project.

For example:

Commit 1
Create project

Commit 2
Add login page

Commit 3
Fix login bug

We will learn how to create commits in detail later.

1.3 What Is the Relationship Between Git and GitHub?

Simply put, Git and GitHub are not the same thing.

Git is a version control tool created by Linus Torvalds, the creator of Linux, in 2005. It was originally developed to manage large open-source projects such as the Linux kernel more efficiently.

GitHub is a Git repository hosting platform launched in 2008. It is built around Git and provides features such as code hosting, Pull Requests, Issues, and team collaboration.

You can use Git normally on your own computer even without GitHub.

Other platforms similar to GitHub include:

  • GitLab
  • Bitbucket
  • Azure DevOps

1.4 Some Common Git Terms

Repository (Repo)

When learning Git, you will frequently see the word Repository, often shortened to Repo.

A Git repository is a project that is managed by Git. In most cases, you can think of it as the project folder containing your code, although this is not a completely precise definition.

For example:

my-project/
├── index.html
├── style.css
├── script.js
└── .git/

The .git/ directory is a special folder used by Git to store version history and repository information.

Commit

A commit is a recorded version of the project. You can think of it as a “save point”.

Commit A
   ↓
Commit B
   ↓
Commit C

If you need to undo the changes introduced by a particular commit, you can use git revert. It creates a new commit that reverses those changes without deleting the original commit history, so Commit C remains available to inspect. Restoring a historical version and undoing a commit are different operations. We will cover them in a later chapter.

Branch

A Branch allows us to create an independent line of development from the current project and make changes without immediately affecting other branches.

For example:

main
  │
  ├── feature-login
  │
  └── feature-search

feature-login can be used to develop the login feature, while feature-search can be used to develop the search feature.

Changes made in the two branches do not automatically affect each other, and the main branch also remains unchanged.

A branch's changes only enter another branch when we explicitly perform a merge.

The main purpose of a branch is to keep different development tasks temporarily independent.

For now, you can think of a branch as:

An independent development path where you can safely modify code without immediately affecting other branches.

Remote

A Remote refers to a remote Git repository, such as a repository hosted on GitHub.

Local Repository
      ↕
Remote Repository

2. Command Line Basics

Because the Git installation process varies depending on the operating system and software version, this tutorial will not cover Git installation. In this section, we will introduce several commonly used basic commands.

Git is often used through the command line.

If you have never used Terminal, PowerShell, or Linux commands before, do not worry. Before learning Git, we only need to understand a few basic commands.

2.1 What Is the Command Line?

The command line can be understood as:

A way to operate your computer by typing text commands.

For example, when you open Terminal on macOS or Linux, you may see something like:

user@computer ~ %

On Windows, you may use PowerShell instead.

Later, we will type Git commands here.

2.2 Check Your Current Location: pwd

pwd stands for:

Print Working Directory

It shows the folder you are currently in.

For example:

pwd

You might get:

/Users/alex

This means you are currently in the user's home directory.

On macOS, Terminal normally opens in your home directory by default.

2.3 View Files: ls

Use:

ls

to view the files and folders in the current directory.

For example:

Desktop
Documents
Downloads
Projects

You can think of it as the command-line equivalent of opening a folder and looking at its contents.

2.4 Enter a Folder: cd

cd stands for:

Change Directory

It changes the folder you are currently working in.

For example:

cd Documents

This enters the Documents folder.

If there is another folder called Projects inside it:

cd Projects

your current location becomes:

Documents/Projects

You can also enter multiple levels of folders at once:

cd Documents/Projects

Go Back to the Parent Directory

Use:

cd ..

For example, suppose your current location is:

Documents/Projects

Run:

cd ..

and you will return to:

Documents

Here:

..

means the parent directory.

2.5 Create a Folder: mkdir

mkdir stands for:

Make Directory

For example:

mkdir git-tutorial

This creates a folder called:

git-tutorial

You can then enter it:

cd git-tutorial

2.6 Clear the Terminal: clear

If there is too much text in the Terminal, you can use:

clear

to clear the current screen.

This does not delete any files, and it does not remove commands you previously executed from the command history.

2.7 Exercise

Create a folder called hello_world inside the Desktop directory, then enter that folder.

The answer will be provided in the next chapter.