• Home
  • DevOps
  • How to Install Git on Linux (Ubuntu) and Mac

How to Install Git on Linux (Ubuntu) and Mac

Last updated on May 27 2022
Suyash Borole

Table of Contents

How to Install Git on Linux (Ubuntu) and Mac

Install Git on Ubuntu

Git is an open-source distributed version control system that is available for everyone at zero cost. It is designed to handle minor to major projects with speed and efficiency. It is developed to co-ordinate the work among programmers. The version control allows you to track and work together with your team members at the same workspace.
Git is the most common source code management (SCM) and covers more users than earlier VCS systems like SVN. Let’s understand how to install Git on your Ubuntu server.
I have done this installation on Ubuntu 16.04 LTS. But the given commands should also work with the other versions.
Below are the steps to install the Git on Ubuntu server:
Step1: Start the General OS and Package update
First of all, we should start the general OS and package updates. To do so, run the below command:
1. $ apt-get update
Now we have started the general OS and package updates. After this, we will run the general updates on the server so that we can get started with installing Git. To do so, run the following commands:
Step2: Install Git
To install Git, run the below command:
1. $ apt-get install git-core
The above command will install the Git on your system, but it may ask you to confirm the download and installation.
Step3: Confirm Git the installation
To confirm the installation, press ‘y’ key on the editor. Now, Git is installed and ready to use.
When the central installation done, first check to ensure the executable file is set up and accessible. The best way to do this is the git version command. It will be run as:
1. $ git –version
Output:
git version 2.24.0
Step4: Configure the Git for the First use
Now you can start using Git on your system. You can explore many features of the version control system. To go with Git, you have to configure the initial user access process. It can be done with the git config command.
Suppose I want to register a user whose user name is “tecklearn” and email address is “Tecklearn@xyz”, then it will be done as follows:
To register a username, run the below command:
1. $ git config –global user.name “tecklearn”
To register an email address for the given author, run the below command:
1. $ git config –global user.email “tecklearn@xyz”
Now, you have successfully registered a user for the version control system.
It’s important to understand that the git config tool works on a user according to the user. For example, if we have a user “john” registered on Git. Then there can be another user “Mike” on the same machine registered on Git. To do this, Mike must run the same command from his user account. The commits made by both the users will be done under their details in Git.

Install Git on Mac

There are multiple ways to install Git on mac. It comes inbuilt with Xcode or its other command-line tools. To start the Git, open terminal and enter the below command:
1. $ git –version
The above command will display the installed version of Git.
Output:
git version 2.24.0 (Apple Git-66)
If you do not have installed it already, then it will ask you to install it.
Apple provides support for Git, but it lags by several major versions. We may install a newer version of Git using one of the following methods:

Git Installer for Mac

This process is the simplest way to download the latest version of Git. Visit the official page of git downloads. Choose the download option for Mac OS X.

devops 27
devops

The installer file will download to your system. Follow the prompts, choose the required installer option. After the installation process completed, verify the installation was successful by running the below command on the terminal:
1. $ git –version
The above command will display the installed version of Git. Consider the below output.
Output:
git version 2.24.0 (Apple Git-66)
Now, we have successfully installed the latest version on our mac OS. It’s time to configure the version control system for the first use.
To register a username, run the below command:
1. $ git config –global user.name “tecklearn”
To register an email address for the given author, run the below command:
1. $ git config –global user.email “tecklearn@xyz”

Installation via MacPorts

Sometimes MacPorts also referred to DarwinPorts. It makes the straightforward installation of software on the Mac OS and Darwin operating systems. If we have installed MacPorts for managing packages on OS X, follow the below steps to install Git.
Step1: Update MacPorts
To update MacPorts, run the below command:
1. $ sudo port selfupdate
Step2: Search for the latest Ports
To search for the most recent available Git ports and variants, run the below command:
1. $ port search git
2. $ port variants git
The above command will search for the latest available port and options and will install it.
Step3: Install Git
To install Git, run the below command:
1. $ sudo port install git
We can also install some extra tools with Git. These tools may assist Git in different manners. To Install Git with bash-completion, svn, and the docs, run the below command:
1. $ sudo port install git +svn +doc +bash_completion +gitweb
Now, we have successfully installed Git with the help of MacPorts on our system.
Step4: Configure Git
The next step for the first use is git configuration.
We will configure the Git username and email address as same as given above.
To register a username, run the below command:
1. $ git config –global user.name “tecklearn”
To register an email address for the given author, run the below command:
1. $ git config –global user.email “tecklearn@xyz”

Install Git via Homebrew

Homebrew is used to make the software installation straight forward. If we have installed Homebrew for managing packages on OS X, follow the below steps to go with Git:
Step1: install Git
Open the terminal and run the below command to install Git using Homebrew:
1. $ brew install git
The above command will install the Git on our machine. The next step is to verify the installation.
Step2: Verify the installation
It is essential to ensure that whether the installation process has been succeeded or not.
To verify whether the installation has been successful or not, run the below command:
1. $ git –version
The above command will display the version that has been installed on your system. Consider the below output:
git version 2.24.0
Step3: Configure Git
We will configure the Git username and email address same as given above.
To register a username, run the below command:
1. $ git config –global user.name “tecklearn”
To register an email address for the given author, run the below command:
1. $ git config –global user.email “tecklearn@xyz”

So, this brings us to the end of blog. This Tecklearn ‘How to install Git on Linux(Ubuntu) and Mac’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Git and GitHub and build a career in DevOps domain, then check out our interactive, Version control with Git and GitHub Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

Version Control with Git and GitHub

Version Control with Git and GitHub Training

About the Course

Tecklearn has specially designed this Git and GitHub Training Course to advance your skills for a successful career in this domain. The course will cover different components of Git and GitHub and how they are used in software development operations. The course consists of important concepts like: branching & merging, how to deal with conflicts, rebasing, merge strategies, Git workflows and so on. You will get an in-depth knowledge of these concepts and will be able to work on related demos. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Git.

Why Should you take Git and GitHub Training?

• Average salary of Git and GitHub Professional is $85k – Indeed.com
• Amazon, Google, Facebook, Microsoft, Twitter, & many other MNC’s worldwide use Git across industries.
• According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.

What you will Learn in this Course?

Introduction to DevOps
• What is Software Development
• Software Development Life Cycle
• Why DevOps?
• What is DevOps?
• DevOps Lifecycle
• DevOps Tools
• Benefits of DevOps
• How DevOps is related to Agile Delivery
• DevOps Implementation
Git and GitHub
• What is version control
• Version Control System (VCS) Products
• Types of VCS
• What is Git
• Why Git for your organization
• Install Git
• Common commands in Git
• Working with Remote Repositories
• GitHub
• Git Installation
• Git Lifecycle
• GitHub (Push, Pull Request)
• GitHub Workflow

0 responses on "How to Install Git on Linux (Ubuntu) and Mac"

Leave a Message

Your email address will not be published. Required fields are marked *