Initializing a Repository: Start Your Git Project Today
Learn how to create a project folder and use git init to transform it into a version-controlled repository. Master the basics of starting your Git workflow.

Previously in this course, we covered Introduction to Version Control, Git Installation, and Configuring User Identity. Now that your environment is ready, it is time to start your first project.
In this lesson, we will transition from theory to practice by creating a project folder and turning it into a managed Git repository.
What is a Git Repository?
A repository (or "repo") is simply a project folder that Git is actively tracking. When you initialize a folder, Git creates a hidden subdirectory called .git inside it. This folder is the "brain" of your project—it stores every version of your files, your commit history, and the configuration settings for that specific project.
Without this hidden folder, Git has no way of knowing what files to watch or where to save your history. By running git init, you are effectively telling Git: "I want to track the changes in this directory."
Creating Your Project Folder

Before we can use Git, we need a place to put our files. Open your terminal (or command prompt) and navigate to the directory where you store your coding projects.
-
Create the folder:
Bashmkdir my-first-project -
Move into the folder:
Bashcd my-first-project
At this point, you are inside a standard, empty directory. If you run ls -a (on macOS/Linux) or dir /a (on Windows), you will see that the directory is empty.
Initializing the Repository with git init
To transform this empty folder into a repository, run the initialization command:
Bashgit init
You should see a message like:
Initialized empty Git repository in /path/to/my-first-project/.git/
If you run ls -a again, you will see a new .git directory. Do not modify the contents of this folder manually. Git manages this directory automatically, and tampering with it can corrupt your project history.
The Workflow Diagram
Understanding the structure is simple. When you run git init, the folder hierarchy changes:
Flow diagram: Project Folder → Your Files; Project Folder → .git folder; .git folder → Configuration; .git folder → Commit History; .git folder → Staging Index
Hands-on Exercise
Let’s verify your setup. Follow these steps to confirm you have a working repository:
- Create a new folder named
git-practiceand navigate into it. - Run
git init. - Run
ls -ato verify the.gitdirectory exists. - Run
git status. You should see an output indicating that you are on the "main" branch and there are "no commits yet."
If you see these results, you have successfully initialized your first repository.
Common Pitfalls
- Initializing in the wrong place: Avoid running
git initin your home directory or a parent folder that contains other projects. You want one repository per project, not one giant repository for your entire computer. - Nested Repositories: Never run
git initinside a folder that is already a Git repository (i.e., don't nest a.gitfolder inside another.gitfolder). This leads to confusing tracking behavior. - Hidden Folders: If you are on Windows, ensure your file explorer is set to "Show hidden files" so you can see the
.gitdirectory when browsing your folders.
FAQ
Q: Can I delete the .git folder? A: Yes, but doing so deletes your entire version history for that project. The files in your project will remain, but they will no longer be tracked by Git.
Q: Does git init upload my code to GitHub?
A: No. git init only creates a repository on your local machine. We will cover how to link this to a remote server like GitHub in a later lesson.
Q: What if I initialized in the wrong folder by mistake?
A: Simply delete the .git folder (rm -rf .git on Unix-based systems, or delete it via File Explorer on Windows) and the directory will revert to a standard, non-Git folder.
Recap
You have now created a project folder and initialized it as a Git repository. This is the fundamental starting point for every project you will build in this course. You have moved from a simple file system to a version-controlled environment.
Up next: Understanding the Git Lifecycle, where we will look at how to move files into the staging area and prepare them for your first save point.
