Learn
🤖 AI Hub 📰 News 📖 Dictionary 🧰 Resources
Grow
💼 Jobs 🚀 Community 🏆 Challenges
Explore by Stage
🌑 Zero 📚 Learn 🔧 Practice 🏗 Build 🚀 Launch 💰 Earn
Account
Login Sign Up
🏗️HTML 🎨CSS ⚡JavaScript 🐙Git & GitHub ⚛️React Soon 📘TypeScript Soon 🐍Python 🗄️Database & SQL Soon 🌐Web Development Soon ☁️Cloud & DevOps Soon 🤖AI & ML Soon 📄Resume Prep Soon 🎤Interview Prep Soon 💼Freelancing Soon 🚀SaaS & Side Projects Soon 🤖Automation Soon
Beginner 🕑 11 min read 👁 3 views 📅 Oct 22, 2026

Your First Repository: init, status, add and commit

Create your first Git repository, check it with git status, stage files with git add, save snapshots with git commit and write clear commit messages.

A Diary for Your Project

Some people keep a diary. Every evening they write the date and a few lines about what happened: “Practised for the dance competition. Finished the poster design.” Months later, they can open the diary and see exactly what happened on any day.

A Git repository is a diary for your project. Each commit is one diary entry: it records the date, the author and a short note about what changed. The big difference is that Git also keeps a full copy of the project as it was at that moment, so you can go back to it.

In this lesson Asha Verma starts the diary for the Utsav fest website. You will learn the four commands you will use every single day: git init, git status, git add and git commit.

Step 1: Create the Repository with git init

A folder becomes a Git repository when you run git init inside it. Asha opens the VS Code terminal in her college-fest-site folder and types:

# Go to the project folder you made in the setup lesson
cd ~/Desktop/college-fest-site

# Turn this folder into a Git repository
git init -b main

The ~ means “my home folder”. The -b main part names the first branch main. If you set init.defaultBranch in the setup lesson, plain git init does the same. You will see something like this (your path will be different):

Initialized empty Git repository in /c/Users/asha/Desktop/college-fest-site/.git/

Git has created the hidden .git folder, the diary itself. To see it, run ls -a; the -a shows hidden files. Run git init only once per project.

Step 2: Ask Git What Is Happening with git status

git status is the command you will type most often. It tells you which files have changed and what Git expects you to do next. It never changes anything, so it is always safe. Asha runs it right away:

On branch main

No commits yet

nothing to commit (create/copy files and use "git add" to track)

Git says three things: she is on the branch main, there are no commits yet, and there is nothing to save because the folder is empty.

Step 3: Create index.html

Asha creates index.html in VS Code with the first version of the fest home page. Press Try it yourself to see what it looks like:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Utsav 2026: College Fest</title>
</head>
<body>
  <h1>Utsav 2026</h1>
  <p>The annual cultural fest of our college. Three days of music, dance, drama and tech!</p>
  <p><strong>Dates:</strong> 14 to 16 February</p>
  <p><strong>Venue:</strong> Main Auditorium and College Ground</p>
</body>
</html>

She saves the file with Ctrl + S and runs git status again:

On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	index.html

nothing added to commit but untracked files present (use "git add" to track)

The file is untracked. That means Git can see a new file in the folder, but it is not watching it yet. In the parcel story from the first lesson, the file is lying on the desk, outside the box.

Step 4: Stage the File with git add

git add moves a change into the staging area, the open box for the next snapshot:

# Put index.html in the staging area (the "box")
git add index.html

# Check again
git status

You will see something like:

On branch main

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   index.html

Now index.html is listed under “Changes to be committed”. It is in the box and ready. You can add files one at a time like this, or add every changed and new file in the folder at once with a dot:

  • git add index.html stages one file
  • git add index.html style.css stages two files
  • git add . stages everything in this folder and the folders inside it
Look before you add everything. git add . is quick, but it also stages files you may not want, such as notes or test files. Run git status first so you know what the dot will include. In the lesson on .gitignore you will learn how to tell Git to skip some files forever.

Step 5: Save the Snapshot with git commit

Now Asha seals the box and writes the label. The -m option means “message”:

# Seal the box and label it: make the first commit
git commit -m "Add home page with fest name, dates and venue"

You will see something like this. Your 7-character code will be different, because every commit gets its own unique hash:

[main (root-commit) a1b2c3d] Add home page with fest name, dates and venue
 1 file changed, 14 insertions(+)
 create mode 100644 index.html

Let us read it: main is the branch, root-commit means this is the very first commit, a1b2c3d is the short hash, and the next lines say one file was saved with 14 lines added. One more git status:

On branch main
nothing to commit, working tree clean

“Working tree clean” means every change is safely committed. The first diary entry is written.

If you forget -m and type only git commit, Git opens your editor (VS Code, if you set it up) so you can type a longer message. Write the message on the first line, save, and close the tab. Git then finishes the commit.

Writing Good Commit Messages

A commit message is a note to your future self and your teammates. In three months, Ravi should understand each commit just by reading its message. Follow these simple rules:

  • Use the imperative form, like giving an instruction: “Add”, “Fix”, “Update”, “Remove”. A good test: the message should finish the sentence “If applied, this commit will...”.
  • Be specific about what changed.
  • Keep it short, about 50 characters or less.
Unclear messageClear message
changesAdd event schedule section
fixed stuffFix wrong date for Dance Battle
updated filesUpdate venue to Main Auditorium
asdfRemove old sponsor logo

Also try to make one commit for one idea. If you added the schedule and also fixed a spelling mistake in the footer, two small commits are better than one big mixed one.

Real-Life Example: The Add and Commit Loop

The next day, Imran sends Asha the event list. She adds an Event Schedule section to index.html. Run it to see the new section:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Utsav 2026: College Fest</title>
</head>
<body>
  <h1>Utsav 2026</h1>
  <p>The annual cultural fest of our college. Three days of music, dance, drama and tech!</p>
  <p><strong>Dates:</strong> 14 to 16 February</p>
  <p><strong>Venue:</strong> Main Auditorium and College Ground</p>

  <h2>Event Schedule</h2>
  <ul>
    <li>Day 1: Opening ceremony and Battle of Bands</li>
    <li>Day 2: Dance Battle and Coding Contest</li>
    <li>Day 3: Street play and Prize distribution</li>
  </ul>
</body>
</html>

She also creates a small style.css file. Now git status shows two kinds of changes: a modified file that Git already tracks, and a new untracked file:

On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   index.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	style.css

no changes added to commit (use "git add" and/or "git commit -a")

Asha uses the same three-step loop that developers use every day:

# 1. See what changed
git status

# 2. Stage the changes you want in this snapshot
git add index.html style.css

# 3. Commit them with a clear message
git commit -m "Add event schedule section and basic styles"

You will see something like:

[main b2c3d4e] Add event schedule section and basic styles
 2 files changed, 12 insertions(+)
 create mode 100644 style.css

This time there is no root-commit, because it is the second entry in the diary. Notice that Git now notices every change to index.html by itself, because the file is tracked. You only need git add to tell Git which changes go into the next snapshot.

Try these changes:

  1. Change the venue line in your index.html, save, and run git status. Git reports the file as modified.
  2. Stage it with git add . and commit it with the message “Update venue for Day 3”.
  3. Run git log --oneline to see your commits listed, newest first. You will explore history properly in the next lesson.

Common Mistakes

  • Running git init in the wrong folder. If you run it in your home folder or Desktop, Git tracks everything there. Always check with pwd first. To undo a wrong git init, delete the hidden .git folder from that place (only if it has no history you need).
  • Committing without adding. If you edit a file and run git commit straight away, Git says “no changes added to commit”. Run git add first.
  • Forgetting to save the file in VS Code. Git only sees what is saved on disk. If the tab shows a white dot, press Ctrl + S before git add.
  • Stuck in a strange editor. If you did not set VS Code as the editor and typed git commit without -m, Git may open an editor called Vim. Press Esc, type :q! and press Enter to leave, then commit again with -m.
  • Vague messages. “update” tells nobody anything. Say what the commit does.

Practice Task: Start Your Own Fest Diary

Do this in your own terminal. Use a new folder called practice-fest so you can experiment freely.

  1. Create the folder on your Desktop, go into it and run git init -b main. Run git status.
  2. Create index.html with the Utsav home page from this lesson. Check git status, add it and commit it.
  3. Add the Event Schedule section, save, and make a second commit.
  4. Create a contact.html page with a heading and the line “Email: utsav@example.com”. Commit it with its own message.
  5. Finish with git status and git log --oneline.

Checklist:

  • You have exactly three commits
  • Every message starts with an action word and says what changed
  • The final git status says “working tree clean”
Show one possible answer (try it yourself first!)
# 1. Create a new folder and make it a repository
cd ~/Desktop
mkdir practice-fest
cd practice-fest
git init -b main
git status

# 2. Create index.html in VS Code (copy the Utsav home page), then:
git status
git add index.html
git commit -m "Add home page with fest name, dates and venue"

# 3. Add the Event Schedule section to index.html and save, then:
git status
git add index.html
git commit -m "Add event schedule section"

# 4. Create contact.html with a heading and an email line, then:
git add contact.html
git commit -m "Add contact page with organiser email"

# 5. Confirm everything is saved
git status
git log --oneline

Key Takeaways

  • git init -b main turns a folder into a repository. Run it once per project.
  • git status shows untracked, modified and staged files. Run it often; it is always safe.
  • git add file or git add . puts changes in the staging area.
  • git commit -m "message" saves a snapshot with a label.
  • Good messages are short, specific and in the imperative form, such as “Add event schedule section”.
  • The daily loop is edit, status, add, commit.

❓ Frequently Asked Questions

Commit whenever you finish one small, complete piece of work, such as a new section or a bug fix. Many small commits are easier to understand and undo than one huge commit at the end of the day.
An untracked file is new, and Git has never saved it in a commit. A modified file is one Git already tracks, and it has changed since the last commit.
Yes. The dot means the current folder and every folder inside it. Run git status first to see what will be included.
No. Git tracks files, not folders. A folder appears in the repository only when it contains at least one committed file.
Was this lesson helpful?

🎯 Finished this lesson?

🔗 Related Tutorials
🤖 Got a Doubt? Ask AI
Get instant answers in Hindi or English
🤖
Z2T Bot
Online
Ask me anything about this tutorial — I'm here! 👋