← All topics

GIT & VERSION CONTROL · START HERE

Your First Saved Version

Follow one small website from an ordinary folder to a local Git commit. No online host or account is needed.

At a glance

Term or command What it means When to use it
Save Writes a file to your computer. Do this in your editor before reviewing your changes.
Stage Selects the current content for the next commit. Use git add for the files you intend to record.
Commit Records a snapshot in local history. Use after reviewing the staged changes.
Push Sends commits to a remote repository. Only needed when sharing with a configured remote; it is not part of this first local example.

Commands are examples, not an interactive terminal. Run them in your own learning repository after checking the prerequisites. Output, paths, commit IDs, and wording can vary. Host-specific instructions are labeled.

1. Prepare the tools

Install Git using the links in Setup and Tools. Open a terminal: Git Bash or PowerShell on Windows, Terminal on macOS, or your Linux terminal. In VS Code, Terminal → New Terminal opens one inside the editor. A terminal runs commands; do not paste them into an HTML file.

Use a new learning folder rather than an existing project. The commands below use a simple folder name without spaces. Run them one at a time.

2. Create the folder

mkdir my-website
cd my-website
git init -b main

Mkdir creates the folder. Cd moves into it. Git init starts history and names the initial branch main. Keep this terminal in my-website for the remaining steps. You will see an initialization message; its absolute path depends on your computer.

3. Identify your commits

Replace these example values with your chosen author name and email. Run inside the new repository. These settings apply only to this project because --global is omitted.

git config user.name "Your Name"
git config user.email "you@example.com"

This is commit authorship, not an online login. Author email becomes part of commit history. If you will publish, choose an address you are comfortable including or a host-provided no-reply address.

4. Save a small file

Open my-website in your editor. Create index.html, paste the document below, and save. Creating the file in the editor keeps this step the same across terminal types.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My Website</title>
</head>
<body>
  <h1>My first version</h1>
</body>
</html>

5. Inspect, stage, and commit

Run inside my-website after saving index.html. Status first shows the new file as untracked. Add selects its saved content. Commit records it locally.

Commands

git status
git add index.html
git diff --staged
git commit -m "Create first webpage"
git status

Example output

[main (root-commit) a1b2c3d] Create first webpage
 1 file changed, 11 insertions(+)
 create mode 100644 index.html

On branch main
nothing to commit, working tree clean

The short commit ID and formatting will vary. A clean working tree means no pending changes among the files Git is reporting. You have recorded a version without GitHub, GitLab, or internet access.

6. Record a second version

In the editor, change the heading to “My updated website” and save. Then run:

git diff
git add index.html
git diff --staged
git commit -m "Update homepage heading"
git log --oneline

Your log now has two commits, newest first. Continue with Everyday Workflow to understand each step. Connect a host only when you are ready to share or keep another copy elsewhere.

Sources and further reading

Study questions

Explain it in your own words, then open the answer.

Did my commit go online?

No. A commit is local. A configured remote and a push are separate steps.

Why did I save before git add?

Git reads saved file content from disk. Unsaved editor text is not staged.

Do I need an account for this walkthrough?

No. Git can initialize, inspect, and commit locally without any hosting account.

What is main?

The branch name chosen for this example. It is not a special online service.

What should git log show after both commits?

Two history entries, with the most recent first.