Git Repository
Now that Git is installed and set up, it's time to start working on a project. For our exercises, we'll be working on a hypothetical university management system.
Step 1: Create a Project Folder
First, let's create a new folder for our project. This will be the place where all our project files will be stored.
- Open your terminal or command prompt.
Type the following commands to create a folder named "university" and move into it:
mkdir university cd university
Inside this folder, create a new file called index.html with the following content:
<p>Welcome to the university</p>
On Linux, you can do this in one step by running:
echo "<p>Welcome to the university</p>" > index.html
Step 2: Initialize a Git Repository
A Git repository is like a special storage space where Git keeps track of all the changes you make to your project files.
You can create a Git repository in two ways:
- Initialize a Local Directory: Turn an existing folder (like our "university" folder) into a Git repository.
- Clone a Repository: Copy an existing Git repository from the internet to your computer.
Let's start by initializing a Git repository in our "university" folder.
- In your terminal, make sure you're still inside the "university" folder.
Type the following command:
git init
You should see a message like this:
Initialized empty Git repository in /home/user/university/.git/
🎖️ Congratulations! You've just created your first local Git repository. This means Git is now tracking everything you do in this folder. You're ready to start building something amazing!