How to install and configure git?

Git official documentation provides exact steps which everyone can follow to install Git on their system based on their system configuration (OS).

You can find the documentation to install Git from here

To check if git is installed on your system, run the following command on terminal / command prompt. This command will return the version of git installed on your system

git --version

I have a script which I’ll run to install git whenever I’m switching to a new laptop. I’ll attach the script file below, you can use it too. This script can run only on Linux (especially Ubuntu flavor). As most developers use Linux and I love using it, I written this script.

Follow the below steps to install Git via script

# Install Git
sudo apt-get update
sudo apt-get -y install git
# Configure Git with your name and email
git config --global user.name "your_name"
git config --global user.email "your_email"
  1. Copy the above content to a file
  2. Replace “your_name” and “your_email” with your name and email respectively
  3. Save the file as install_git.sh
  4. On terminal, navigate to the folder where you saved the file
  5. Make the file executable by running the below command on terminal
sudo chmod +x install_git.sh

Note: This step will ask you to enter your system password

4. Run the file using the below command

./install_git.sh

Run git --version to verify the installation of Git. This command will return the version of git installed on your system.

That’s it. We’re done with setting up git on your local machine.

Remember to save the install_git.sh file in a safe place to install git quickly in your system, if you switch your laptop in future.

Please follow my instagram account to receive quick updates

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store