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.
cd path/to/your/project2. Initialize the Git Repository
Run the following command:
git initThis 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:
git statusGit will show all the files that are not yet tracked.
Example output:
Untracked files:
index.html
style.css
script.js4. Add Files to Git
To start tracking your files, add them to the staging area:
git add .The . means add all files in the project.
You can also add a specific file:
git add filename.exp5. Create the First Commit
Once the files are staged, create your first commit:
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 :
rm -rf .git