Course contents

Initialize a new Git repository

Try it now → Free demo · sign in to save progress

Learn

A Git repository — "repo" for short is any folder that Git is watching. When you tell Git to start watching a folder, it drops a hidden .git/ sub-folder into it, and everything Git knows about your project history, branches, configuration lives inside that folder.

The command that turns a plain folder into a repo is:

git init

Run it, and Git prints something like:

Initialized empty Git repository in /work/.git/

That's it. Your folder is now a Git repo. To convince yourself, list the folder contents with ls -la (the -a flag shows hidden entries) and you'll see .git/ sitting there next to your own files.

But there's no history yet

A brand new repo has no commits. Git is watching, but you haven't asked it to record anything. If you run:

git status

Git will happily reply, telling you the current branch and that "No commits yet". That's not an error it's Git saying "I'm ready, you haven't given me anything to save."

git status is the command you'll run more than any other. It answers "what does Git think is going on right now?" run it constantly as you work.

main, not master

You may see older tutorials use master as the default branch name. Modern Git uses main. Same concept, different label. The sandbox below is set up for main.

What "the repo is just files" means

The .git/ folder is a plain directory of plain files. There's no Git service running in the background, no cloud account, no daemon. When people say a repo lives on GitHub, what actually lives there is a copy of that .git/ folder. Deleting .git/ un-Gits a folder completely; there's no other state to clean up.

Keep this mental model — Git is files — and everything in the rest of the course will feel more concrete.

Your task

Initialize a brand-new Git repository in an empty directory. After running the command, git status should show a clean working tree on the default branch with no commits yet.

Try it now →