Skip to Content
DevopsGitInitialize a ProjectExisting Project

Initialize an Existing Project

If you already have a project on your computer and want to start tracking it with Git, you can initialize a Git repository inside the project folder.


1. Navigate to Your Project Directory

Open your terminal and move to your project folder using cd.

Terminal
cd path/to/your/project

2. Initialize the Git Repository

Run the following command:

Terminal
git init

This command creates a hidden .git folder in your project.

The .git directory contains all the information Git needs to track changes in your project.

After running the command, your project becomes a Git repository.

3. Check the Repository Status

You can check the current state of your repository using:

Terminal
git status

Git will show all the files that are not yet tracked.

Example output:

Untracked files: index.html style.css script.js

4. Add Files to Git

To start tracking your files, add them to the staging area:

Terminal
git add .

The . means add all files in the project.

You can also add a specific file:

Terminal
git add filename.exp

5. Create the First Commit

Once the files are staged, create your first commit:

Terminal
git commit -m "Initial commit"

A commit saves a snapshot of your project at a specific point in time.

Supprimer un dépôt Git :

Terminal
rm -rf .git
Last updated on