Version control is an essential tool for anyone who develops software or works with code. Git is one of the most popular version control systems that allows you to manage your projects effectively and access different versions at any time. In this tutorial, I will show you how to create a Git repository to safely store your project and maintain a clear structure.
Key Insights
- Git enables easy management and tracking of version changes.
- The repository creation is done with the command git init.
- You can check the status of the repository with git status.
Step-by-Step Guide
Before you can create a repository, you need to ensure that you have the necessary software packages installed and that you are in the directory where you want to create the repository.
Step 1: Open Terminal and Navigate to the Correct Directory
First, open your terminal and navigate to the directory that you want to use for your project. If you are unsure where to go, use the command ls to list the directories. The starting directory could be, for example, "git example".

Familiarize yourself with the terminal: Here you see the directory you are working in.
Step 2: Create the Repository
To create a new repository, use the command git init. This command initializes an empty Git repository in the current directory. Make sure to specify the directory where you want to create the repository, e.g., in "git example".
After executing the command, you will receive confirmation that the empty Git repository has been successfully created. A hidden.git file will be created that stores all the necessary information about your project.
Step 3: Check the Repository Status
The next step is to check the status of your repository. Use the command git status for this purpose. This command provides information about the current state of your repository, especially regarding the presence of untracked (not tracked) files.
You should see that your repository has a branch-Master and that it displays information about untracked files, which means there are files that need to be added to version control.
Step 4: Identify Untracked Files
Untracked files are files that have not yet been added to version control. When you check the status, you will see a list of these files in the output of the command. These files need to be tracked before any changes can be saved.
In this state, however, you cannot commit anything yet, as there are no changes that can be captured.
Step 5: Add Files to the Repository
To save your changes, you need to add the desired files to the repo. However, you should not do this hastily. In the next step of the tutorial, you will learn how to select the right files and possibly ignore some to allow for clean and effective management.
Now you have laid the foundation for your version control and can delve deeper into the topic in the next tutorial, such as using.gitignore or adding new files.
Summary – Version Control with Git – Creating a Repository
In this tutorial, you learned how to create a Git repository, starting from the directory structure to basic Git commands like git init and git status. These steps are the foundations for effectively managing your software projects and ensuring that all changes are documented and easily traceable.
Frequently Asked Questions
How do I create a new Git repository?You can create a new Git repository using the command git init.
What does the command git status do?The command git status shows you the current state of your repository and lists untracked files.
How do I add new files to my Git repository?You can add new files to your repository using the command git add.
What is a branch in Git?A branch is a separate line of development within your repository where you can make changes without affecting the main code.