Welcome to our comprehensive guide designed to help beginners master the basics of Git through command-line interactions. Git, an essential tool for version control, is a fundamental skill in modern software development. Knowing its commands will enable you to collaborate effectively with other developers, manage your projects' history, and work efficiently. Let's dive in!

By the end of this tutorial, you'll be comfortable with the most common Git commands, understand how to navigate your project's history, and know how to collaborate with others using a remote Git repository. No prior experience is required, just a willingness to learn!

Understanding and Setting up Git
Before we start using Git, let's first understand what it is and how to set it up on your system.

Git is an open-source, distributed version-control system that tracks changes in source code during software development. It's used extensively in collaboration, ensuring that everyone on the team is working from the latest version of the project.
Installing Git

To use Git, you first need to install it on your system. Here's how you can do it on popular platforms:
- On Windows: Download the Git for Windows installer from the official site, and follow the prompts to install it.
- On macOS: If you have Homebrew installed, you can install Git using the command:
brew install git. Otherwise, download the macOS Git installer from the official site. - On Linux: On most Linux distributions, you can install Git using the package manager. For example, on Ubuntu, run:
sudo apt install git.
Configuring Git

After installing Git, you'll need to configure it with your personal details using these commands:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
initialize and Clone Git Repositories
Now that you've set up Git, let's start using it to manage a version-controlled project.

Every Git repository begins with an initial commit and can be initialized using the git init command. If you're working on an existing project that's already version-controlled, you can clone it to your local machine using git clone.
Initializing a New Git Repository




















To initialize a new Git repository in your current working directory, enter:
git init
This command will create a new folder named ".git" in your repository, containing all the necessary information for Git to track the project's history.
Cloning an Existing Git Repository
To clone an existing project, you'll need its URL (usually on a service like GitHub, GitLab, or Bitbucket). Here's how to clone the repository:
git clone
Replace https://github.com/username/repo-name.git with the URL of the repository you want to clone. The cloned repository will be placed in a new folder with the same name as the repository.
Tracking Changes and Committing
Now that you have your Git repository set up, let's start tracking changes and committing them to the project's history.
Every time you make changes to your files, Git will track them. You can then selectively add these changes to a "staging" area, and finally commit them with a meaningful message.
Tracking and Staging Changes
Git starts tracking changes in your repository as soon as you make them. To see a list of all tracked and untracked changes, enter:
git status
To add specific changes to the staging area, use the git add command. You can add individual files, folders, or even track changes from the entire project:
git add filename
git add .
Committing Changes
Once you've staged the changes you want to commit, use the git commit command to save them to the project's history. Alongside this command, write a meaningful commit message in quotes, describing the changes made:
git commit -m "Commit message describing the changes made"
Try to be descriptive and concise in your commit messages. They should clearly explain what the commit contains and why the changes were made.
Browsing and Understanding the Project's History
Git keeps a full history of all previous versions of your project. Let's explore how to view this history and understand what each commit contains.
Every commit has a unique ID, a timestamp, an author, and a commit message. By looking at this history, you can navigate back to any previous version of the project.
Viewing the Project's History
To view the full history of your project, enter:
git log
This command will display a list of all commits, showing the commit ID, author, timestamp, and commit message.
Viewing a Specific Commit
To view the details of a specific commit, including the changes it contains, enter:
git show
Replace with the ID of the commit you're interested in. Git will display a summary of the commit's changes and the diff details.
Now that you've learned the basics of Git, it's time to start practicing and getting comfortable with these commands. As you gain experience, you'll find that Git becomes an invaluable tool for managing your projects and collaborating with other developers. Happy coding!