Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing Git on Linux, Mac OS X and Windows

Installing Git on Linux

Determine on which Linux distribution your system is based on. See List of Linux distributions – Wikipedia for a list. Most Linux systems – including Ubuntu – are Debian-based.

Debian-based linux systems

Open a terminal window. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.

sudo apt update
sudo apt upgrade
sudo apt install git

You can use Git now.

Red Hat-based linux systems

Open a terminal. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.

sudo yum upgrade
sudo yum install git

You can use Git now.

Installing Git on a Mac

Open a terminal window.

Step 1 – Install Homebrew

Homebrew […] simplifies the installation of software on the Mac OS X operating system.

Homebrew – Wikipedia

Copy & paste the following into the terminal window and hit Return.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew doctor

You will be offered to install the Command Line Developer Tools from Apple. Confirm by clicking Install. After the installation finished, continue installing Homebrew by hitting Return again.

Step 2 – Install Git

Copy & paste the following into the terminal window and hit Return.

brew install git

You can use Git now.

Installing Git on Windows

  1. Download Git from Git for Windows and install it.
@alhadhrami

This comment has been minimized.

Copy link

@alhadhrami alhadhrami commented Nov 9, 2017

Wrong link in 'intro.md' for "Instructions for Windows". I was going to create a pull request, but then remembered that doesn't exist in gist.

@rgnest

This comment has been minimized.

Copy link

@rgnest rgnest commented Jan 6, 2018

You shoud before do "cd" the directrory should be yours home. Or will have error.
I mean macos.

@mithlesh4257

This comment has been minimized.

Copy link

@mithlesh4257 mithlesh4257 commented Jan 7, 2018

screenshot from 2018-01-07 22-15-52

Git is not installing in Ubuntu. Please help!

@elseagle

This comment has been minimized.

Copy link

@elseagle elseagle commented Jan 18, 2018

@mithlesh4257 try
sudo apt-get update then sudo apt-get upgrade followed by sudo apt-get install git

@Kaarthick912

This comment has been minimized.

Copy link

@Kaarthick912 Kaarthick912 commented Mar 5, 2018

sudo yum upgrade

I ran this command and it removed all existing users. It upgraded like 450 packages and removed some users. Anybody know why this happened ?

@Aztechtcs

This comment has been minimized.

Copy link

@Aztechtcs Aztechtcs commented Mar 11, 2018

same problem here

@Joshua56

This comment has been minimized.

Copy link

@Joshua56 Joshua56 commented Mar 30, 2018

I am having the same problem in my linux mint

@Joshua56

This comment has been minimized.

Copy link

@Joshua56 Joshua56 commented Mar 30, 2018

zenity : Depends: libpango-1.0-0 (>= 1.14.0) but it is not going to be installed
Depends: zenity-common (= 3.18.1.1-1ubuntu2) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a s

This the error of the code

@reddyvenu

This comment has been minimized.

Copy link

@reddyvenu reddyvenu commented Apr 10, 2018

same problem here

@imad-bouramana

This comment has been minimized.

Copy link

@imad-bouramana imad-bouramana commented Apr 29, 2018

try this repository

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

@webbertakken

This comment has been minimized.

Copy link

@webbertakken webbertakken commented Aug 15, 2018

I used this as a source for PracticalNotes - Homebrew.md because it is very efficient.

@oscrx

This comment has been minimized.

Copy link

@oscrx oscrx commented Sep 13, 2018

Wrong link in 'intro.md' for "Instructions for Windows". I was going to create a pull request, but then remembered that doesn't exist in gist.

Exactly this :D
But thanks for the guide.

@Princewillsarlex

This comment has been minimized.

Copy link

@Princewillsarlex Princewillsarlex commented Nov 15, 2018

17636731_434178160268231_2603838547563642880_n

@adkumar321

This comment has been minimized.

Copy link

@adkumar321 adkumar321 commented Jan 18, 2019

try this

sudo apt-get install aptitude

sudo aptitude install git

@DuncantheeDuncan

This comment has been minimized.

Copy link

@DuncantheeDuncan DuncantheeDuncan commented Mar 9, 2019

Thanks it now installed
But Git-it command doesn't work and git-it verify
So what the next step please help
I'm using Kali Linux

@NetJayNoob

This comment has been minimized.

Copy link

@NetJayNoob NetJayNoob commented Mar 19, 2019

I am having issues with setting the port. When I type 'set port 80' I get back as an error: "you can't set option 'port'. Available options: ['target', 'http_port'" etc.... will this affect my check runs later?

This is on Kali Linux, and is after 'set target 192.168.....)

@Anthomy1

This comment has been minimized.

Copy link

@Anthomy1 Anthomy1 commented May 30, 2019

Thanks it now installed
But Git-it command doesn't work and git-it verify
So what the next step please help
I'm using Kali Linux

Same here

@Anthomy1

This comment has been minimized.

Copy link

@Anthomy1 Anthomy1 commented May 30, 2019

I need help.
I'm using Kali Linux.
Screenshot from 2019-05-30 17-48-45

@virgilwashere

This comment has been minimized.

Copy link

@virgilwashere virgilwashere commented Jun 4, 2019

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

Install git on Ubuntu

From the launchpad git-core ppa

The most current stable version of Git for Ubuntu.

For release candidates, go to https://launchpad.net/~git-core/+archive/candidate .
More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa

sudo add-apt-repository ppa:git-core/ppa --yes --update
sudo apt-get install git --yes
apt commands output
$ sudo add-apt-repository ppa:git-core/ppa --yes --update
gpg: keyring `/tmp/tmpk8m4os6a/secring.gpg' created
gpg: keyring `/tmp/tmpk8m4os6a/pubring.gpg' created
gpg: requesting key E1DF1F24 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpk8m4os6a/trustdb.gpg: trustdb created
gpg: key E1DF1F24: public key "Launchpad PPA for Ubuntu Git Maintainers" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK
$ sudo apt-get install git --yes
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  git-man libpcre2-8-0
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  libpcre2-8-0
The following packages will be upgraded:
  git git-man
...
Preparing to unpack .../git_1%3a2.21.0-0ppa1~ubuntu16.04.1_amd64.deb ...
Unpacking git (1:2.21.0-0ppa1~ubuntu16.04.1) over (1:2.7.4-0ubuntu1.6) ...
Preparing to unpack .../git-man_1%3a2.21.0-0ppa1~ubuntu16.04.1_all.deb ...
Unpacking git-man (1:2.21.0-0ppa1~ubuntu16.04.1) over (1:2.7.4-0ubuntu1.6) ...
Selecting previously unselected package libpcre2-8-0:amd64.
Preparing to unpack .../libpcre2-8-0_10.21-1_amd64.deb ...
Unpacking libpcre2-8-0:amd64 (10.21-1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Setting up libpcre2-8-0:amd64 (10.21-1) ...
Setting up git-man (1:2.21.0-0ppa1~ubuntu16.04.1) ...
Setting up git (1:2.21.0-0ppa1~ubuntu16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
$ git --version
git version 2.21.0
hub version 2.11.2

hub: use github from the command-line
hub is an extension to command-line git that helps you do everyday GitHub tasks without ever leaving the terminal

Hope that helps someone.

Virgil

@virgilwashere

This comment has been minimized.

Copy link

@virgilwashere virgilwashere commented Jun 4, 2019

@Anthomy1

I'm using Kali Linux.

From: https://docs.kali.org/general-use/kali-linux-sources-list-repositories

⚠️ Any additional repositories added to the Kali sources.list file will most likely BREAK YOUR KALI LINUX INSTALL.

If this doesn't do it, I'd be real careful now...

sudo apt-get update
sudo apt-get install git
@sagynov

This comment has been minimized.

Copy link

@sagynov sagynov commented Jun 16, 2019

nice

@Knlsharma

This comment has been minimized.

Copy link

@Knlsharma Knlsharma commented Jul 22, 2019

Use this command to check your current Git version: git --version

@Lucifer8759

This comment has been minimized.

Copy link

@Lucifer8759 Lucifer8759 commented Jul 23, 2019

I need help.
I'm using Kali Linux.
Screenshot from 2019-05-30 17-48-45

@mark-nirdesh

This comment has been minimized.

Copy link

@mark-nirdesh mark-nirdesh commented Dec 17, 2019

I need help.
I'm using Kali Linux.
Screenshot from 2019-05-30 17-48-45

why use shell ?
use sudo apt-get install git

@ocBruno

This comment has been minimized.

Copy link

@ocBruno ocBruno commented Feb 14, 2020

Just a heads up!
The Instructions for Windows is linking to the linux instructions

@CyberChick111

This comment has been minimized.

Copy link

@CyberChick111 CyberChick111 commented Mar 6, 2020

@mithlesh4257 try
sudo apt-get update then sudo apt-get upgrade followed by sudo apt-get install git

This one worked!! Thanks

@Phontera

This comment has been minimized.

Copy link

@Phontera Phontera commented Mar 31, 2020

It worked! Thank you.

@gprakarsh

This comment has been minimized.

Copy link

@gprakarsh gprakarsh commented Aug 10, 2020

The link for the Mac Download is outdated. This is the one that should be used -
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

@ASCassinda

This comment has been minimized.

Copy link

@ASCassinda ASCassinda commented Aug 25, 2020

buhhiih

@Cyber-Guy24

This comment has been minimized.

Copy link

@Cyber-Guy24 Cyber-Guy24 commented Sep 3, 2020

Thanks mark-nirdesh that worked for me as well

@wajeehas

This comment has been minimized.

Copy link

@wajeehas wajeehas commented Sep 13, 2020

I have tried installing homebrew via mac os terminal, but it keeps asking me for a password. does anyone know which password this is? it comes up as a key sign.
Screenshot 2020-09-13 at 21 56 42

@derhuerst

This comment has been minimized.

Copy link
Owner Author

@derhuerst derhuerst commented Sep 14, 2020

I have tried installing homebrew via mac os terminal, but it keeps asking me for a password. does anyone know which password this is? it comes up as a key sign.

It looks like it uses sudo to install itself to a specific location on your computer; sudo requires your password. You will have to put your macOS user's password.

This is badly designed, it should actually explain why it is using sudo.

@mahfudivan

This comment has been minimized.

Copy link

@mahfudivan mahfudivan commented Sep 23, 2020

I have tried installing homebrew via mac os terminal, but it keeps asking me for a password. does anyone know which password this is? it comes up as a key sign.
Screenshot 2020-09-13 at 21 56 42

your laptop password, I use a macbook, I also enter my laptop password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.