How to initialize a Git repository

Starting version control for a new project is the foundation of professional software development and collaborative coding. As the creator of CoreUI, a widely used open-source UI library, I’ve initialized countless Git repositories across various projects over 25 years of development. From my expertise, the most straightforward approach is using the git init command in your project directory to create a new local repository. This sets up the essential .git directory structure for tracking your project’s history.

Use git init command to initialize a new Git repository in your project directory.

git init
git init my-project

Here the first command initializes Git in the current directory, creating a hidden .git folder that contains all version control metadata. The second command creates a new directory called my-project and initializes Git inside it. After initialization, you can start tracking files with git add and create your first commit with git commit.

Best Practice Note:

This is the same repository setup approach we use for all CoreUI projects and components. After initializing, immediately create a .gitignore file to exclude unnecessary files, and consider setting up your remote repository connection with git remote add origin for backup and collaboration.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.

Answers by CoreUI Core Team