Initialize A Repository
Part of the Version Control section of Coddy's Terminal journey — lesson 4 of 58.
Before Git can track a folder, you have to initialize it as a repository. The command for this is git init:
git initRun this once inside any folder you want to track. Git creates a hidden subfolder called .git/ that holds the entire history, configuration, and internal data of the repository.
You only need to run git init once per project. After that the folder is a Git repository forever (or until you delete the .git/ folder).
Git will print a confirmation message similar to:
Initialized empty Git repository in /path/to/project/.git/Challenge
BeginnerInitialize the current folder as a Git repository, then list all files (including hidden ones) so you can see the new .git folder.
Use ls -A for the listing. It shows hidden entries but skips . and ...
Cheat sheet
Initialize a folder as a Git repository with git init (run once per project):
git initThis creates a hidden .git/ subfolder that stores the entire history and configuration. Deleting .git/ removes the repository.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore