← Git from Scratch Lesson 2 of 17 · 10 XP

git init — create a repository

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

git init turns an ordinary folder into a repository: it creates a hidden .git folder inside it.

git init
# Initialized empty Git repository in /repo/.git/

Everything git knows about the project lives in .git: the history, the branches, the settings. Delete .git and the folder becomes ordinary again, and the whole history disappears. Your working files stay, though.

The main branch of a new repository is called main. In older versions of git and older projects you'll see the name master.

You run git init once per project. If the project already exists on GitHub, instead of init you run git clone <url> — more on that in the lesson about remote repositories.

Task. Create a repository with git init, then look at the hidden files with ls -a. You'll see .git there.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.