git init
The `git init` command creates a new, empty Git repository in the current folder. It adds a hidden `.git` directory that stores all the history, branches, and configuration for that project.
You only run `git init` once per project, when you're starting version control from scratch. If you're joining an existing project hosted online, you would use `git clone` instead.
git initCreating a repository
Navigate to your project folder and run `git init`. This turns an ordinary folder into a Git repository able to track changes.
The .git folder
git init creates a hidden `.git` folder containing all repository data. Deleting this folder removes all Git history but leaves your files untouched.
mkdir my-project
cd my-project
git initInitialized empty Git repository in /my-project/.git/Creates a new folder and initializes it as a Git repository.
git init existing-folderInitialized empty Git repository in existing-folder/.git/Initializes Git inside an existing folder by passing its name as an argument.
Key points
- git init creates a new local Git repository.
- It adds a hidden .git folder that stores all history.
- You run it once per project when starting from scratch.
- Use git clone instead when copying an existing remote project.
