Skip to main content
March 23, 2026/3 min read

How to Create a Git Repository: git init

Master Version Control with Essential Git Commands

What is a Git Repository

A Git repository contains all project files and the complete revision history, transforming an ordinary folder into a version-controlled workspace with tracking capabilities.

Git Repository Components

Project Files

Your actual code, documents, and assets that make up your project. These are the files you actively work with and modify.

Git Metadata

Hidden .git folder containing all version control information, tracking changes, branches, and commit history automatically.

Revision History

Complete timeline of all changes made to your project, allowing you to view, compare, and revert to previous versions.

A Git repository (or repo for short) serves as the complete foundation for your project's version control system, containing both your current project files and the entire revision history of every change made over time. When you initialize Git in an ordinary folder of files—whether it's a website's root directory, a mobile app codebase, or any software project—Git creates a hidden .git subfolder that houses all the metadata necessary for tracking changes, managing branches, and coordinating team collaboration.

Understanding Git's file structure is crucial for effective development workflow. On Unix-based operating systems such as macOS and Linux, files and folders that begin with a period (.) are automatically hidden from standard file browsers. This means you won't see the .git folder in macOS Finder or most GUI file managers unless you explicitly enable the display of hidden files. However, most professional code editors like VS Code, Sublime Text, and Vim will display these hidden directories in their file explorers, giving you visibility into your repository's internal structure when needed.

TIP: On macOS, you can quickly toggle the visibility of hidden files in Finder by pressing Cmd+Shift+Period (.). This keyboard shortcut is invaluable for developers who need to access configuration files and hidden directories.

Initialize a Git Repo

Creating your first Git repository is straightforward, but the implications are significant—you're establishing the foundation for professional version control that will serve your project throughout its entire lifecycle.

  1. In your terminal (Terminal on macOS/Linux, Git Bash on Windows, or Windows Command Prompt), navigate to the root folder of your project using the cd command. Ensure you're in the correct directory by running pwd (print working directory) to confirm your location.

  2. Execute this fundamental command:

    git init

    This command transforms your ordinary directory into a Git repository, creating the hidden .git folder and establishing the initial branch (typically called "main" in modern Git configurations). You'll see a confirmation message indicating that an empty Git repository has been initialized.

Creating Your First Git Repository

1

Navigate to Project Folder

Open your terminal application and use cd command to navigate to the folder you want to convert into a Git repository

2

Execute git init Command

Run the git init command to initialize the repository and create the hidden .git subfolder with all necessary metadata

3

Verify Repository Creation

Check that the .git folder was created successfully, noting it may be hidden on Unix-based systems like macOS

Viewing Hidden Files on macOS

Press Cmd-Shift-Period to toggle visibility of hidden files and folders in macOS Finder, allowing you to see the .git directory.

Before vs After git init

FeatureBefore git initAfter git init
Folder StructureRegular project folderProject folder with .git subfolder
Version ControlNo tracking capabilitiesFull Git tracking enabled
File VisibilityAll files visible.git folder hidden by default
Git CommandsCommands not availableAll Git commands functional
Recommended: The git init command transforms a regular folder into a fully functional Git repository with version control capabilities.

Go Beyond Git

Mastering Git is just the beginning of your development journey. As version control becomes second nature, you'll want to expand your technical expertise across the full spectrum of modern development practices.

We offer comprehensive coding courses and intensive bootcamps designed for professionals at every stage of their career—from those making their first transition into tech to experienced developers looking to master new technologies. Our curriculum emphasizes hands-on learning with real-world applications, and students receive detailed workbooks with step-by-step instructions through practical exercises that mirror actual industry challenges.

Available Programming Courses

Web Development

Comprehensive hands-on courses covering modern web technologies with real-world applications and step-by-step workbooks for practical learning.

Python Programming

Learn Python fundamentals and advanced concepts through interactive exercises designed for students at all experience levels.

Data Science

Master data analysis, visualization, and machine learning techniques with practical projects and industry-standard tools.

Web Design

Develop creative and technical skills for modern web design with focus on user experience and visual aesthetics.

Hands-On Learning Approach

Pros
Interactive exercises with real-world applications
Step-by-step workbooks provided to all students
Courses designed for all experience levels
Practical skills development focus
Cons
Requires active participation and engagement
May have steeper learning curve for beginners
Location-specific courses in NYC area

Next Steps After Learning Git

0/4

Key Takeaways

1A Git repository contains both project files and complete revision history for version control
2The git init command transforms any folder into a Git repository by creating a hidden .git subfolder
3The .git folder contains all Git metadata and is hidden by default on Unix-based systems like macOS
4Use Cmd-Shift-Period on macOS to toggle visibility of hidden files including the .git directory
5Terminal navigation to the target folder is required before executing the git init command
6Some code editors may display the .git folder even when it's hidden in the file system
7Git initialization enables all version control capabilities for tracking changes and managing project history
8Professional coding courses offer hands-on learning with workbooks and real-world applications for skill development

RELATED ARTICLES