Skip to main content

How to initialize git?

Initializing Git is creating a new Git repository in the project folder.


Basic method (most common)

  1. Open the terminal
  2. Navigate to the project folder:
bash
cd path/to/project
  1. Run the command:
bash
git init

After this:

  • a hidden .git/ directory appears in the folder
  • the project becomes a Git repository
  • Git starts tracking file changes

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.