Getting Started with Git: Installation & Setup Guide
What is Git?
Git is a free and open-source tool used to track changes in code. It works well for both small and large projects. It is fast and helps developers work better together.
Also, Git does not rely on a central server. This means you can work offline and still track changes. As a result, teams can work together smoothly, even if they are in different places.
Git Benefits?
- Efficiency: Git offers fast and seamless tracking of code changes, making it easy to manage your codebase and merge updates from other branches.
- Reliability: With strong community support and widespread adoption, Git minimizes the risk of code loss, ensuring the integrity and security of your projects.
- Flexibility: Git is highly adaptable—you can track virtually any file type and customize workflows to suit your development needs.
How to install git?
Here’s how you can install Git on your local machine.
Ubuntu:
-
Open the Terminal
PressCtrl + Alt + Ton your keyboard to open the terminal. -
Update the Package List
sudo apt-get update
- Install Git
sudo apt-get install git
- Verify Installation
git --version
Windows
- Download the Git for Windows installer from the official Git website: Download.
- Run the installer and follow the instructions in the setup wizard.
- When prompted, select the default options or choose your preferred settings.
How to set up your Git username and email globally or for individual repositories?
These commands set your Git username and email globally, meaning they will apply to all Git operations on your system
git config —global user.name “Your Name”
git config —global user.email “your.name@example.com”
If you want to set your username and email for a specific repository only, navigate to that repository and run:
cd /path/to/repository
git config user.name “Your Name”
git config user.email “your.name@example.com”
Note: You can only set one global username and email. If you want to use a different one for a specific project, you’ll need to set it separately inside that project’s repository.
Here are a few additional details about the git config command:
-
The
--globaloption tells Git to apply the settings to all repositories on your computer. -
user.nameanduser.emailare the values Git uses to identify you as the author of commits. -
You can use any name and email, but it’s best to use ones that match your other online identities (e.g., GitHub, GitLab).