Skip to Content
DevopsGitInitialize a ProjectNew Project

Initialize a New Project

If you are starting a brand-new project, you can create a new directory and initialize it as a Git repository. This allows Git to track all changes from the beginning of the project.


1. Create a New Project Folder

First, create a new directory for your project.

Terminal
mkdir my-project cd my-project git init

2. Initialize the Git Repository

Run the following command to initialize Git:

Terminal
git init

This command creates a hidden .git folder inside your project directory. The .git folder contains all the metadata and history Git uses to manage the repository.

Your project is now a Git repository.

3. Create Your First File

Add a file to your project. For example:

Terminal
touch README.md

You can open this file and add a short description of your project.

4. Add Files to the Staging Area

Tell Git to start tracking your files:

Terminal
git add .

The . means add all files in the current directory.


Git lifecycle diagram
Last updated on