Setup and Initialize Git
Course Title: Version Control Systems: Mastering Git Section Title: Introduction to Version Control Topic: Set up Git on your machine and create your first repository.(Lab topic)
Objective: In this lab session, you will learn how to set up Git on your machine, create a new repository, and understand the basic workflow of a Git-based project.
Materials Needed:
- A computer with internet access
- A text editor or IDE (Integrated Development Environment) of your choice
- Git software (download link: https://git-scm.com/downloads)
Step 1: Download and Install Git
To get started with Git, you need to download and install it on your machine. Follow these steps:
- Go to the official Git website (https://git-scm.com/downloads) and click on the download link for your operating system (Windows, macOS, or Linux).
- Once the download is complete, follow the installation instructions for your operating system.
- On Windows, you can use the Git Bash terminal emulator to run Git commands.
- On macOS and Linux, you can use the Terminal application.
Step 2: Verify Git Installation
After installing Git, you need to verify that it is working correctly. Open your terminal or command prompt and type the following command:
git --version
This should display the version of Git that you just installed.
Step 3: Set up Git Configuration
Before creating a new repository, you need to set up your Git configuration. This includes setting up your name and email address that will be associated with your commits. Run the following commands:
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
Replace "Your Name"
and "your_email@example.com"
with your actual name and email address.
Step 4: Create a New Repository
To create a new repository, follow these steps:
- Create a new directory for your project and navigate to it using the
cd
command. - Initialize a new Git repository using the
git init
command:
This will create a newgit init
.git
directory in your project directory, which is where Git will store all the version control data. - Create a new file, for example,
hello.txt
, and add some content to it. - Run the
git status
command to see the status of your repository:
This should display the new file that you just created.git status
Step 5: Understand the Git Workflow
Now that you have created a new repository, it's essential to understand the basic Git workflow. Here's a simple overview:
- Create a new file or modify an existing one.
- Stage the changes using the
git add
command. - Commit the changes using the
git commit
command. - Push the changes to a remote repository using the
git push
command.
We will cover these commands in detail in the next topic: "Basic Git commands: init, clone, add, commit, status."
Conclusion:
In this lab session, you have successfully set up Git on your machine, created a new repository, and understood the basic Git workflow. You are now ready to learn more about the basic Git commands that will help you manage your version control projects effectively.
Comments and Questions:
If you have any questions or concerns about this topic, feel free to leave a comment below. Your feedback is valuable to us, and we will do our best to answer your questions.
Next Topic:
In the next topic, "Basic Git commands: init, clone, add, commit, status," you will learn about the essential Git commands that will help you create, manage, and share your version control projects.
Additional Resources:
For more information about Git, you can refer to the official Git documentation (https://git-scm.com/doc). Additionally, you can watch video tutorials and online courses on Git to improve your skills.
Images

Comments