How to Download Git (for Different Operating Systems)-Part 1

Bana Ibrahim
4 min readFeb 20, 2021

Are you new to git and you want to download it properly?! Are you facing errors like ( gpg: Warning: using insecure memory! ) when you start using git ?? This might be due to improper downloading of git.

In this blog I’ll explain the proper way of downloading git for each operating system.

GnuPG:

Before downloading git, you have to download GnuPG (a.k.a GPG):

  • What is GnuPG ??

GNU Privacy Guard is an encryption program, that let’s people communicate privately online. It works by converting messages to unreadable form (attached with the public key of a recipient) before sending them over the internet, then the recipient is the only one who can convert them back to the readable form using his/her private key 🔑.

Image source
  • Why you have to download GPG first ??

Git will fail to do anything if it doesn’t know you, so the first thing you should do after installing git is to set your name and email, but these info are not enough, and this error will be returned:

gpg: Warning: using insecure memory!

So a secure and reliable way is needed to identify who did this in git, and GPG is the best fit. (GPG key will be the signing key in git)

1. Download GPG for Windows system:

  1. Download it from Gpg4win. (for the donation just select $0 if you don’t want to)
  2. Run the downloaded installation file.
  3. Follow the instructions, and make sure that GPA is ticked; as it will be used in generating GPG key.

4. After the installation, two icons will appear on the desktop for (GPA & Kleopatra), open the GPA. The "Generate Key" window will pop up, enter your name and email.

Note: if you want to use GitHub (for hosting codes), make sure you enter the verified email address for your GitHub account.

5. Then another window will appear for the Passphrase (should be strong, memorable, and kept secret).

6. GPG key is now successfully generated.

To follow up the next steps read part 2 of the blog….

2. Download GPG for Linux and mac OS :

GPG usually comes pre-installed, to know that check the version, by running this in terminal.

gpg --version

If it’s not found, try:

gpg2 --version

If it’s found scroll down to the generating key step. If it’s not, you have to install it.

Now it’s your choice to install GPG or GPG2 ( GPG2 is an extended version of GPG ).

** In Linux **

  • For Debian based systems:
sudo apt install gnupg 
  • For rpm based systems:
sudo yum install gnupg

If you chose GPG2 just write gnupg2 instead of gnupg.

** In mac **

The easiest way to download GPG is by using homebrew (a management system that simplifies the installation of software packages).

First check if the homebrew is installed.

brew -v or brew --version

If it’s not found, install it with this command:

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

Now, install GPG:

brew install gpg

Or GPG2:

brew install gpg2

How to Generate GPG key?

Run the command below; to generate gpg key (for gpg2: just replace gpg with gpg2).

gpg --gen-key

Then, you’ll be asked multiple questions:

  1. Firstly, you’ll be asked the kind of key you want (RSA, DSA, …)? keep the default and hit Enter.
  2. Secondly, you’re going to specify the size of the key (default: 2048). It’s better to specify longer size, so just write the max-size 4096.
  3. Then you’ll be asked to specify the validity period of the key (default: 0 , means valid forever). For example, if you want your key to expire after 3 years just enter 3y.
  4. Now, enter your name and email. Also you’ll be asked to write a comment, you can leave it empty. But if you have multiple GPG keys, comment is useful to identify each key.

Note: if you want to use GitHub (for hosting codes), make sure you enter the verified email address for your GitHub account.

5. Next question is for confirming your info: Is this correct? (y/N). Type y to proceed.

6. Finally, enter a Passphrase (should be strong, memorable, and kept secret). GPG key is now successfully generated.

To follow up the next steps read part 2 of the blog….

--

--

Bana Ibrahim
0 Followers

Bioinformatician | Explain things related to (git, data science, ML) in a simple way.