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.
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.



