Now that you have Git installed, it's time to create your very first Git repository! A repository, or 'repo' for short, is essentially a project folder that Git will track. Every change you make, every file you add or modify, will be recorded within this repository, allowing you to go back in time, collaborate with others, and manage your project's evolution. We'll start by creating a local repository directly on your computer.
First, navigate to the folder on your computer where you want to create your project. You can do this using your terminal or command prompt. For example, if you want to create a new project folder named 'my-first-project' on your Desktop, you might use commands like these (adjust the path to your actual Desktop location):
cd Desktop
mkdir my-first-project
cd my-first-projectOnce you're inside the directory where you want your project to live, the magic command to initialize a Git repository is git init. This command creates a hidden subfolder named .git within your project directory. This .git folder is where Git stores all the history and metadata for your repository. Don't worry about its contents for now; Git manages it for you.
git initAfter running git init, you'll see a message confirming that an empty Git repository has been initialized. Your project folder is now a Git repository, ready to start tracking changes!
graph TD
A[Project Folder] --> B(Initialize Git Repository);
B --> C[.git folder created];
C --> D[Repository ready to track changes];
To verify that your repository has been initialized, you can run the git status command. This command tells you the current state of your repository, including which files are being tracked and which are not. Initially, after git init, it will likely show that you have no commits yet and no files are staged for commit.