Loading lessons...
Project 1: My First Repository
Project 1: My First Repository
Let's build a small project from scratch and track it with Git.
Step 1: Create a project folder
mkdir my-blog
cd my-blog
Step 2: Initialize Git
git init
Step 3: Create a file
Create index.html and add a simple page:
<!DOCTYPE html>
<html>
<head><title>My Blog</title></head>
<body>
<h1>Welcome to my blog</h1>
<p>First post coming soon.</p>
</body>
</html>
Step 4: Set your identity
git config user.name "Your Name"
git config user.email "you@example.com"
(Use your real name and email.)
Step 5: Check status
git status
Your file shows up as untracked.
Step 6: Stage and commit
git add .
git commit -m "Add home page"
Step 7: Check your history
git log --oneline
You now have your very first commit.
Bonus
- Edit index.html, then
git addandgit commitagain. - Run
git log --onelineto see both commits.
TL;DR
git initstarts a repository.git add .stages everything.git commit -m "message"saves a snapshot.git log --onelineshows your history.