AI Hints
Home›Git & GitHub Tutorial›Your First Repository
Git & GitHub · Lesson 5 of 144

Your First Repository

Git init.

⏱ 2 min read▶ Video at 4:40🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

A folder that Git is watching is called a repository, or repo for short. Any folder can become a repository, with one command. Let's make one.

Your First Repository
From the video: Your First Repository
  • A repository is a folder Git watches
  • Any folder can become one
  • With one command

Make a folder, then git init

First we make a new folder called my site, with make dir, and move into it with c d. Now the magic command. Git init. Git says it initialized an empty repository. From now on, Git can track every file in this folder.

git
mkdir my-site
cd my-site
git init
Initialized empty Git repository in /Users/sam/projects/my-site/.git/

What just happened

Git init doesn't change your files. It just adds a hidden folder called dot git. That's where Git keeps all your snapshots and history. The repository is simply your folder, plus that hidden dot git folder.

keyvalue
Your filesstay exactly as they are
.gita hidden folder
Inside .gitevery snapshot
Repositoryfolder + .git

Summary

git init turns any folder into a repository, by adding a hidden dot git folder. Next, let's peek inside it.

Key takeaways
  • mkdir and cd
  • git init
  • Adds a hidden .git folder
Next up: The Hidden .git Folder — where history lives