How to use git for beginners

Published: 7/7/2025

Are you lost every time you use Git and GitHub?

Or are you confused about the difference between the two?

As a legend has put it: “git is to github as porn is to pornhub.”

Very straightforward, very clear. But it’s still not apparent to beginners who still don’t really know what git is.

And this is what we will go through in this newsletter.

When you play games that have more than one level, there are checkpoints that you can go back to when your character dies (unless you are playing The Game Of Sisyphus).

You can create “checkpoints” of your code, so that you can go back to a previous version when you mess it up.

That tool is git.

But it doesn’t happen automatically. You have to run commands.

Here’s the 2-step process to use it in your projects:

1. git init

The first step is to run git init in your project. This creates a .git folder (usually called a git repository).

Let’s say your current location is (/home/project1). After you run git init, a folder is created in this path : (/home/project1/.git/)

The .git folder will store all the checkpoints (formally called commits).

Git works independently in different projects. You can create a git folder in any folder.

2. git add & git commit

The next step is to create commits.

Let’s say there are three files in your project, which are file A, B & C.

To create the first version of your code, you run “git add .” and “git commit -m ‘first commit’”

“git add .” tells git which files you want to track in this checkpoint. The ‘.’ tells means track all files.

“git commit” creates the checkpoint. You use -m to write a description of this commit.

You can run git log to see the commit:

commit 063d003ce9ff4083772fa832e335b75ae1da44ba (HEAD -> master)

Author: animecoders

Date: Tue Jun 17 16:39:23 2025 +0800

first commit

063d003ce9ff4083772fa832e335b75ae1da44ba” is the commit ID.

The (HEAD -> master) could be confusing because we haven’t talked about what a branch is. But it means we are in a branch called master, and we are currently in this version. Don’t worry about it for now, you will get it sooner or later.

And the “first commit” is the commit message that describes this commit.

Now let’s create another commit.

You made some changes to file A, and you want to save it. This will be version 2 of your code. Again, you run:

  • “git add fileA” or “git add .” Both works, because git is smart enough to only track files that have changed.
  • git commit -m ‘second commit’

Now you have two versions of the code:

commit 8480a1ddd26b5da9a64d96915d16730e555afd00 (HEAD -> master)

Author: animecoders

Date: Tue Jun 17 16:44:45 2025 +0800

second commit

commit 063d003ce9ff4083772fa832e335b75ae1da44ba

Author: animecoders

Date: Tue Jun 17 16:39:23 2025 +0800

first commit

See that (HEAD -> master) is now next to our latest commit? It means that we are at the latest version of our code. You can move the HEAD pointer with git checkout.

Now you understand how to create checkpoints for your code. To go respawn in previous checkpoints, you can use reset, restore, and revert, each with some nuances. It has enough content to write another newsletter about.

Next week, you will learn how GitHub works.

The cheat code to become a programming master

Easy-to-digest tips and tutorials that help you get ahead of other developers.