You have read about what Git is and why it exists. Now it is time to open a terminal and actually use it. This article walks you through every step — from getting Git onto your computer to making your very first permanent snapshot of a project — and explains what is happening at each stage, not just which keys to press.

Step 1 — Installing Git

Git is a program that lives on your computer, not in a browser. Before you can use it, you need to install it. The good news is that on many systems it is already there. Open a terminal and type:

bash
$ git --version
git version 2.47.0
If you see a version number, Git is already installed and you can skip ahead to Step 2.

If you get a "command not found" error instead, you need to install Git. The diagram below shows what is happening when you install it, and where it ends up on your machine.

DOWNLOAD Official installer git-scm.com or package manager install GIT BINARY Installed on your system /usr/bin/git C:\Program Files\Git /usr/local/bin/git available from PATH YOUR TERMINAL Type any git command git init git commit Where to get it Where it lives Where you use it Windows winget install Git.Git or git-scm.com/download/win macOS brew install git or git-scm.com/download/mac Linux sudo apt install git-all or git-scm.com/download/linux
Figure 1 — Git is a program installed on your machine and called from any terminal. Official installers for all platforms are available at git-scm.com/downloads.

Once the installation finishes, run git --version again to confirm it worked. If you see a version number, you are ready.

Step 2 — Telling Git Who You Are

Before Git will let you make your first commit, it needs to know your name and email address. This is not optional. Every commit you ever make will be permanently stamped with this information — it is how, in a shared project, everyone can see who made which change and when. Think of it as signing your work before it goes into the archive.

You only need to do this once per computer. The --global flag means "apply this to every repository on this machine."

bash
$ git config --global user.name "Ada Lovelace"
$ git config --global user.email ada@example.com
$ git config --global init.defaultBranch main
$ git config --list
user.name=Ada Lovelace
user.email=ada@example.com
init.defaultbranch=main
Figure 2 — Run these three commands once, right after installation. The last one, git config --list, confirms everything was saved correctly.

The third command — init.defaultBranch main — tells Git that every new repository should start on a branch called main. This arrived in Git 2.28 and has since become the modern standard. Without it, older versions of Git default to a branch called master. Setting it now avoids any inconsistency later.

Step 3 — Creating Your First Repository

A repository is just a regular folder that you have asked Git to watch over. Create one, step into it, and hand Git the keys with a single command: git init.

bash
$ mkdir my-project
$ cd my-project
$ git init
Initialized empty Git repository in /home/ada/my-project/.git/
Figure 3 — git init creates a hidden .git subfolder inside your project. That folder is Git's entire memory for this repository.

What just happened? Git created a hidden folder called .git inside your project. You will never need to open it, but it is worth knowing it is there. It holds Git's entire memory of your project: every snapshot you ever take, every commit message, every author name. If you delete the .git folder, Git forgets everything — your actual files remain, but the history is gone. If you copy the project folder somewhere else, the .git folder comes along and the history comes with it.

Step 4 — The Core Workflow: Edit, Stage, Commit

Here is the rhythm you will repeat for the rest of your career with Git. Every change you make goes through three stages: you edit a file in your working directory, you stage it to prepare it for a snapshot, and you commit it to record that snapshot permanently. Start by creating a file:

bash
$ echo "# My Project" > README.md
Figure 4 — Creating a simple README file. Any text editor works just as well.

Reading the Room: git status

Before doing anything else, ask Git what it sees. This is the command you will run more than any other — before staging, after staging, after committing, whenever you feel uncertain about where things stand.

bash
$ git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present
(use "git add" to track)
Figure 5 — git status gives you a live report. Notice that Git even tells you what to do next — the output is designed to guide you.

"Untracked" means Git can see the file but is not watching it yet. It exists in your working directory, but Git has made no promise to remember it. Notice also that Git itself suggests the next step: "use git add to track." The output of git status is always trying to tell you something useful — read it carefully.

Moving to the Staging Area: git add

Staging is the step that surprises most beginners. Why not just commit directly? The reason is that the staging area gives you control. It lets you choose exactly which changes become part of the next snapshot, even if you have touched multiple files. You might have fixed a bug and added a new feature at the same time — staging lets you turn those into two clean, separate commits instead of one confusing lump.

bash
$ git add README.md
$ git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
Figure 6 — After git add, the file moves from "untracked" (red) to "Changes to be committed" (green). It is now in the staging area — queued for the next snapshot.

The colour shift from red to green in the terminal output is Git's visual cue that something has moved between areas. The file has not been saved to history yet — but it is ready to be.

Taking the Snapshot: git commit

Now you record the snapshot permanently. The -m flag lets you write the commit message inline. A commit message is a note to your future self — treat it seriously.

bash
$ git commit -m "Add README with project title"
[main (root-commit) 4f2a9c1] Add README with project title
1 file changed, 1 insertion(+)
create mode 100644 README.md
Figure 7 — Git confirms the commit with the branch name, the short hash (4f2a9c1), the message, and a summary of what changed. Your first snapshot is now permanent.

A good commit message uses the imperative mood — write it as if giving the project an instruction. "Add README with project title" reads as a clear, purposeful action. "added stuff" or "fix" tells your future self absolutely nothing. In six months, when something breaks and you are scanning through the history trying to find the culprit, you will be grateful for every commit message that actually explains what changed and why.

Reading Your History: git log

Every commit is recorded chronologically. At any point you can ask Git to show you the full history of the project so far.

bash
$ git log
commit 4f2a9c1d8e3b7f6a5c4d2e1f0a9b8c7d6e5f4a3b
Author: Ada Lovelace <ada@example.com>
Date: Tue May 5 10:14:22 2026 +0100
Add README with project title
$ git log --oneline
4f2a9c1 Add README with project title
Figure 8 — git log shows the full history. git log --oneline is more compact and useful once you have several commits.

The long string of letters and numbers is the commit hash — a unique fingerprint computed from everything in that snapshot: the file contents, the message, the author, the date, and the hash of the previous commit. Change any single character anywhere and the hash would be completely different. This is what makes Git's history tamper-proof.

Putting It All Together: a Real Walkthrough

Here is the complete sequence — building up a small project from scratch, making two commits, and reading the final history. Every command is one you just learned.

bash — full project walkthrough
# 1. Create the project folder and initialise Git
$ mkdir weather-cli && cd weather-cli
$ git init
Initialized empty Git repository in /home/ada/weather-cli/.git/
# 2. Create the first file
$ echo "# weather-cli — prints local weather in your terminal" > README.md
# 3. Ask Git what it sees
$ git status
Untracked files: README.md
# 4. Stage and commit the first snapshot
$ git add README.md
$ git commit -m "Add README with project description"
[main (root-commit) 7c3d1a2] Add README with project description
# 5. Add more content and make a second commit
$ echo "## Install: pip install weather-cli" >> README.md
$ git add README.md
$ git commit -m "Document install command in README"
[main 9b4e2f1] Document install command in README
# 6. View the two-commit history
$ git log --oneline
9b4e2f1 Document install command in README
7c3d1a2 Add README with project description
Figure 9 — A complete two-commit project built from scratch. The history reads from newest (top) to oldest (bottom).

In about ten commands you created a version-controlled project with a clean, readable history. Both commits are permanent. Both can be recovered. Both tell a clear story of what changed and why.

Three Mistakes Every Beginner Makes

Knowing the commands is not enough — knowing where things go wrong is just as valuable. Here are the three stumbles that catch almost everyone at this stage.

01
Forgetting git add
Most common
You edit a file and run git commit directly. Git replies "nothing to commit." Remember: editing moves a file to the working directory, but only git add moves it to the staging area. Nothing reaches history without passing through staging first.
02
Vague commit messages
Second most common
"fix", "stuff", "update", "wip" — every developer has written these. They are useless the moment you step away for a week. Write in the imperative mood: "Fix crash when username is empty." Keep the subject line under 50 characters.
03
Not checking what happened
Easily avoided
git status and git log are free. Run them constantly — after every add, after every commit, whenever you feel uncertain. The most common cause of "I broke Git" is guessing instead of asking. Git always knows where things stand; let it tell you.

Nothing Is Ever Really Lost

One thing worth knowing before you go further: once something is committed, it is exceptionally hard to lose. Even if you later run a command that seems destructive — deleting a branch, doing a hard reset — Git keeps a private journal called the reflog that records every position HEAD has ever been in. If you commit your work regularly, you have a safety net that most people do not even know exists.

The lesson is simple: commit early and commit often. Uncommitted work sitting only in your working directory is the only work that is genuinely fragile. Every time you commit, you add another save point to your timeline — and save points are free.

Main References

  1. Chacon, S., & Straub, B. Pro Git (2nd ed.). Apress. Chapters 1.5 (Installing Git), 1.6 (First-Time Setup), 2.2 (Recording Changes), 2.3 (Viewing the Commit History).
    https://git-scm.com/book/en/v2
  2. Git Project. Official Downloads. git-scm.com.
    https://git-scm.com/downloads
  3. Atlassian. Git init — Atlassian Git Tutorial.
    https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init
  4. GitHub Docs. Setting your commit email address.
    https://docs.github.com/en/account-and-profile/…/setting-your-commit-email-address
  5. Beams, C. (2014). How to Write a Git Commit Message. cbea.ms.
    https://cbea.ms/git-commit/
← Back to all articles