What is Git
Git is a distributed version control system (DVCS) created by Linus Torvalds in 2005 to manage Linux kernel development. It allows multiple developers to work on a project simultaneously without overwriting each other's changes. Git tracks changes to files and directories over time, enabling users to revert to previous versions, compare changes, and collaborate efficiently.
Quick History of Git
Before Git, the Linux kernel project relied on a proprietary DVCS called BitKeeper. In 2005, the relationship between the Linux kernel community and BitKeeper's developers deteriorated, leading Linus Torvalds to develop Git. Git was designed to handle the high velocity and complexity of Linux kernel development. It quickly gained popularity and has since become the standard for version control in the software industry.
Who uses Git
Git is used by a vast range of developers and organizations, from individual open-source contributors to large enterprises. Notable users include:
Software Developers: To track changes, collaborate, and manage codebases.
DevOps Teams: For continuous integration and deployment (CI/CD) pipelines.
Project Managers: To oversee project progress and manage feature development.
Designers and Writers: To version control digital assets and documents.
Git vs. GitHub: What's the Difference
Git: Git is a version control system that runs locally on your machine. It enables you to track changes, revert to previous states, and branch out to experiment without affecting the main project.
GitHub is a web-based platform that hosts Git repositories. It adds a social collaboration layer with features such as pull requests, issue tracking, and project management tools. GitHub facilitates remote collaboration, making sharing your work with others and contributing to public repositories easy.
Installation and Setup
Before you can start using Git, install it on your local machine and configure some basic settings. This section will guide you through installing different operating systems and initial setup.
Installing Git on Windows
Download Git:
Visit the official Git website: Git for Windows
Click on the download link to get the latest version of Git for Windows.
Run the Installer:
Locate the downloaded
.exe
file and run it.Follow the setup wizard. You can generally accept the default settings. However, there are a few steps worth noting:
Adjusting your PATH environment: Ensure the option "Git from the command line and 3rd-party software" is selected.
Choosing the SSH executable: Use the bundled OpenSSH.
Configuring the line ending conversions: Choose "Checkout Windows-style, commit Unix-style line endings" for the best compatibility.
Verify the Installation:
Open a command prompt (CMD) or PowerShell.
Type
git --version
and press Enter. If installed correctly, you will see the version of Git that was installed.
Installing Git on Mac
Using Homebrew:
If you have Homebrew installed, you can install Git by opening the Terminal and typing:
brew install git
Using the Git Installer:
Alternatively, you can download the Git installer from the official Git website: Git for Mac
Run the downloaded
.dmg
file and follow the installation instructions.
Verify the Installation:
Open the Terminal.
Type
git --version
and press Enter. If installed correctly, you will see the version of Git that was installed.
Configuring Your Name and Email
Once Git is installed, you need to configure your user information, which will be used for all your commits. This step is essential because Git attaches this information to each commit you make.
Open Your Command Line Interface:
On Windows, open Command Prompt or PowerShell.
On Mac, open Terminal.
Set Your Name:
Type the following command and press Enter:
git config --global user.name "Your Name"
Replace
"Your Name"
with your actual name.
Set Your Email:
Type the following command and press Enter:
git config --global user.email "[email protected]"
Replace
"[email protected]"
with your actual email address.
Verify Configuration:
To verify that your configuration is correct, type:
git config --global --list
You should see your name and email listed among other configurations like this:
By following these steps, you will have Git installed and configured on your machine, ready for use in version control of your projects. Next, we'll dive into the basics of Git to familiarize you with how it works.