Git Basics
This tutorial will guide you through the basic Git operations using the command line interface.
Step 1: Install Git
First, you need to ensure that Git is installed on your computer. You can check this by typing the following command in your bash terminal:
git --version
If Git is installed, you will see the version number. If not, you will need to install Git.
Step 2: Configure Git
Next, configure your Git username and email using the following commands:
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
Step 3: Initialize a Git Repository
Create a new directory, navigate into it, and initialize a new Git repository:
mkdir git-practice
cd git-practice
git init
Step 4: Create a File
Create a new file in the directory:
echo "Hello, Git!" > hello.txt
Step 5: Check Git Status
Use the git status
command to see the status of your repository:
git status
Step 6: Stage Changes
Add the new file to the staging area:
git add hello.txt
Step 7: Commit Changes
Commit the changes with a message:
git commit -m "Add hello.txt"
Step 8: View Commit History
Finally, view the commit history of your repository:
git log
Congratulations! You have completed the basic Git operations. Keep practicing these commands until you feel comfortable with them.