3. Putting the project under version control

Recording changes

At this stage, the repository doesn't contain any files or changes. Yes, we have the file hello.html in the working tree, but it's not yet under version control. We need to explicitly add any changes to the repository.

A change in the Git repository is called a

. You can think of a commit as a snapshot of the repository at a certain point in time. It contains all the changes that were made since the last commit. You can also add a message to the commit to describe what changes were made.

Before creating a commit, we need to tell Git what changes we want to put into that commit. In Git terms, we need to add all the relevant changes to the

. It's a fancy way of selecting files that we want to add to the next commit.

Now let's add our "Hello, World!" page to version control. To do that, we will use the

command. After the command, we pass an argument—the file we want to add to the staging area. In our case, it's hello.html.

Run in Terminal:
git add hello.html
Task
Completed

Add the file hello.html to the staging area of the repository.

Now, we're about to make our first commit. We can do that using the

command like this:

Run in Terminal:
git commit -m "Initial commit"

The important option here is -m (shorthand for --message), which lets us write the commit message inline. A good commit message briefly explains what changed so your future self and your team can understand the history. If you leave out -m, Git opens your default text editor and asks you to write the message there.

If you ran the commit command without the -m option, you may have noticed that your terminal changed: the history is gone and you are presented with a blank screen. This is the text editor Git opened for your commit message. You can write the message, save it, and close the editor to complete the commit. The editor is usually a

like vim or nano.

Sounds easy. What could go wrong? People not familiar with these editors may find it difficult to even exit them. If you're one of them, here are some videos that will help you exit these editors: Vim, Nano.

If nothing helps, close the terminal tab or window, then open a new one and start over.

In the example above, the "Initial commit" piece is the value of the -m option, our commit message. Note that the commit message should be in quotes so that the whole message is treated as a single value. It will be recorded without the wrapping quotes.

Task
Completed

Commit the file hello.html to the repository.

You should see something like this as the output:

Result:

[main (root-commit) 571a4dd] Initial commit 1 file changed, 1 insertion(+) create mode 100644 hello.html

It's a good practice to divide independent changes into separate commits. For example, if you added a new feature and fixed a bug, it's better to make two separate commits instead of one. This way, you can easily revert the new feature without losing the bug fix. This practice is called

.

The technical name for the staging area is the index. In GitByBit, we'll usually say staging area because it describes what you use it for: preparing changes for the next commit.

Next step
Wanna try the Story mode?

Take the course as it was meant to be taken: bite-sized progression, focused linear order, gradually unlock Gitopedia entries. Continue with real Git in VS Code/Cursor/Antigravity/Windsurf at any time.

Story mode
FREE
but requires sign-in