How to install git linux
How to install git linux
Installing Git
Before you start using Git, you have to make it available on your computer. Even if it’s already installed, it’s probably a good idea to update to the latest version. You can either install it as a package or via another installer, or download the source code and compile it yourself.
This book was written using Git version 2.8.0. Though most of the commands we use should work even in ancient versions of Git, some of them might not or might act slightly differently if you’re using an older version. Since Git is quite excellent at preserving backwards compatibility, any version after 2.8 should work just fine.
Installing on Linux
If you want to install the basic Git tools on Linux via a binary installer, you can generally do so through the package management tool that comes with your distribution. If you’re on Fedora (or any closely-related RPM-based distribution, such as RHEL or CentOS), you can use dnf :
If you’re on a Debian-based distribution, such as Ubuntu, try apt :
For more options, there are instructions for installing on several different Unix distributions on the Git website, at https://git-scm.com/download/linux.
Installing on macOS
There are several ways to install Git on a Mac. The easiest is probably to install the Xcode Command Line Tools. On Mavericks (10.9) or above you can do this simply by trying to run git from the Terminal the very first time.
If you don’t have it installed already, it will prompt you to install it.
If you want a more up to date version, you can also install it via a binary installer. A macOS Git installer is maintained and available for download at the Git website, at https://git-scm.com/download/mac.
Installing on Windows
There are also a few ways to install Git on Windows. The most official build is available for download on the Git website. Just go to https://git-scm.com/download/win and the download will start automatically. Note that this is a project called Git for Windows, which is separate from Git itself; for more information on it, go to https://gitforwindows.org.
To get an automated installation you can use the Git Chocolatey package. Note that the Chocolatey package is community maintained.
Installing from Source
Some people may instead find it useful to install Git from source, because you’ll get the most recent version. The binary installers tend to be a bit behind, though as Git has matured in recent years, this has made less of a difference.
If you do want to install Git from source, you need to have the following libraries that Git depends on: autotools, curl, zlib, openssl, expat, and libiconv. For example, if you’re on a system that has dnf (such as Fedora) or apt-get (such as a Debian-based system), you can use one of these commands to install the minimal dependencies for compiling and installing the Git binaries:
In order to be able to add the documentation in various formats (doc, html, info), these additional dependencies are required:
Users of RHEL and RHEL-derivatives like CentOS and Scientific Linux will have to enable the EPEL repository to download the docbook2X package.
If you’re using a Debian-based distribution (Debian/Ubuntu/Ubuntu-derivatives), you also need the install-info package:
If you’re using a RPM-based distribution (Fedora/RHEL/RHEL-derivatives), you also need the getopt package (which is already installed on a Debian-based distro):
Additionally, if you’re using Fedora/RHEL/RHEL-derivatives, you need to do this:
due to binary name differences.
When you have all the necessary dependencies, you can go ahead and grab the latest tagged release tarball from several places. You can get it via the kernel.org site, at https://www.kernel.org/pub/software/scm/git, or the mirror on the GitHub website, at https://github.com/git/git/releases. It’s generally a little clearer what the latest version is on the GitHub page, but the kernel.org page also has release signatures if you want to verify your download.
Then, compile and install:
After this is done, you can also get Git via Git itself for updates:
Установка Git
Прежде чем использовать Git, вы должны установить его на своём компьютере. Даже если он уже установлен, наверное, это хороший повод, чтобы обновиться до последней версии. Вы можете установить Git из собранного пакета или другого установщика, либо скачать исходный код и скомпилировать его самостоятельно.
В этой книге используется Git версии 2.8.0. Хотя большинство используемых нами команд должны работать даже в старых версиях Git, некоторые из них могут не работать или действовать немного иначе, если вы используете старую версию. Поскольку Git отлично справляется с сохранением обратной совместимости, любая версия после 2.8 должна работать нормально.
Установка в Linux
Если вы хотите установить Git под Linux как бинарный пакет, это можно сделать, используя обычный менеджер пакетов вашего дистрибутива. Если у вас Fedora (или другой похожий дистрибутив, такой как RHEL или CentOS), можно воспользоваться dnf :
Если же у вас дистрибутив, основанный на Debian, например, Ubuntu, попробуйте apt :
Чтобы воспользоваться дополнительными возможностями, посмотрите инструкцию по установке для нескольких различных разновидностей Unix на сайте Git https://git-scm.com/download/linux.
Установка на Mac
Существует несколько способов установки Git на Mac. Самый простой — установить Xcode Command Line Tools. В версии Mavericks (10.9) и выше вы можете добиться этого просто первый раз выполнив ‘git’ в терминале.
Если Git не установлен, вам будет предложено его установить.
Если Вы хотите получить более актуальную версию, то можете воспользоваться бинарным установщиком. Установщик Git для OS X доступен для скачивания с сайта Git https://git-scm.com/download/mac.
Установка в Windows
Для установки Git в Windows также имеется несколько способов. Официальная сборка доступна для скачивания на официальном сайте Git. Просто перейдите на страницу https://git-scm.com/download/win, и загрузка запустится автоматически. Обратите внимание, что это отдельный проект, называемый Git для Windows; для получения дополнительной информации о нём перейдите на https://gitforwindows.org.
Для автоматической установки вы можете использовать пакет Git Chocolatey. Обратите внимание, что пакет Chocolatey поддерживается сообществом.
Установка из исходников
Многие предпочитают устанавливать Git из исходников, поскольку такой способ позволяет получить самую свежую версию. Обновление бинарных инсталляторов, как правило, немного отстаёт, хотя в последнее время разница не столь существенна.
Если вы действительно хотите установить Git из исходников, у вас должны быть установлены следующие библиотеки, от которых он зависит: autotools, curl, zlib, openssl, expat и libiconv. Например, если в вашей системе используется dnf (Fedora) или apt-get (системы на базе Debian), вы можете использовать одну из следующих команд для установки всех зависимостей, используемых для сборки и установки бинарных файлов Git:
Для того, чтобы собрать документацию в различных форматах (doc, html, info), понадобится установить дополнительные зависимости:
Пользователи RHEL и производных от неё (таких как CentOS или Scientific Linux) должны подключить репозиторий EPEL для корректной установки пакета docbook2X
Если вы используете систему на базе Debian (Debian/Ubuntu/Ubuntu-производные), вам так же понадобится установить пакет install-info :
К тому же из-за различий имён бинарных файлов вам понадобится сделать следующее:
Когда все необходимые зависимости установлены, вы можете пойти дальше и скачать самый свежий архив с исходниками из следующих мест: с сайта Kernel.org https://www.kernel.org/pub/software/scm/git, или зеркала на сайте GitHub https://github.com/git/git/releases. Конечно, немного проще скачать последнюю версию с сайта GitHub, но на странице kernel.org релизы имеют подписи, если вы хотите проверить, что скачиваете.
Затем скомпилируйте и установите:
После этого вы можете получать обновления Git посредством самого Git:
Установка Git в Ubuntu
Одной из самых популярных систем управления версиями заслуженно считается Git. Многие проекты хранят свои файлы в репозиториях Git, а сайты GitHub и Bitbucket сделали обмен исходным кодом очень простым. В этой небольшой статье будет рассмотрена установка Git в Ubuntu. Мы рассмотрим два способа установки, а также начальную конфигурацию.
Установка Git с помощью пакетного менеджера
Самый простой способ установить Git в Ubuntu 20.04 или других версиях, это использовать пакетный менеджер apt и официальные репозитории Ubuntu. Это самый быстрый и простой метод, но вы получите не самую свежую версию.
Для установки Git с помощью пакетного менеджера. сначала обновим списки пакетов из репозиториев:
sudo apt update
Затем осталось загрузить и установить программу:
sudo apt install git
После этого программа будет установлена и вы можете переходить к ее настройке. Для просмотра версии выполните:
Установка Git из исходных кодов
Перед тем, как приступить нам нужно будет скачать пакеты, от которых зависит Git. Все есть в официальном репозитории, поэтому вы можете все сделать с помощью пакетного менеджера:
sudo apt update
sudo apt install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
После того как все будет установлено вы можете скачать архив с самыми последними версиями исходного кода. Это можно сделать на странице релизов. Здесь есть как rc релизы, так и стабильные версии.
Распакуйте только что загруженный файл с помощью unzip и переместитесь в каталог с файлами архива:
unzip git.zip
cd git-*
Дальше переходим к сборке программы и ее установке:
make prefix=/usr/local all
sudo make prefix=/usr/local install
После того как вы установили Git таким способом, вы можете просто ещё раз клонировать репозиторий и выполнить две последние команды для обновления. Для клонирования нужно знать URL репозитория. Например, для текущей ветки master, этот url будет выглядеть вот так:
git clone https://github.com/git/git
Затем просто соберите новую версию git с помощью тех же команд:
cd git
make prefix=/usr/local all
sudo make prefix=/usr/local install
После выполнения старая версия будет заменена новой. Причем, старые исходники сохранятся, так что в случае ошибок вы сможете восстановить старую версию. А теперь давайте рассмотрим как выполнить минимальную настройку Git, чтобы с программой можно было работать.
Настройка Git в Ubuntu
После того как установка Git Ubuntu будет завершена одним из выше перечисленных способов, вам нужно еще кое-что сделать перед тем, как вы сможете полноценно работать. Вам нужно идентифицировать себя указав имя пользователя и адрес электронной почты.
Вы можете посмотреть установленные параметры с помощью команды:
Вся информация хранится в вашем конфигурационном файле Git, поэтому вы можете отредактировать его вручную если это необходимо с помощью текстового редактора:
[user]
name = Имя
email = youremail@domain.com
Здесь можно установить много других параметров, но именно эти два самые важные, потому что если вы попытаетесь что-то сделать когда они не установлены, то увидите предупреждение:
Выводы
How to install git linux
How to install Git on any OS
Git can be installed on the most common operating systems like Windows, Mac, and Linux. In fact, Git comes installed by default on most Mac and Linux machines!
Checking for Git
To see if you already have Git installed, open up your terminal application.
Install Git Using GitHub Desktop
Installing GitHub Desktop will also install the latest version of Git if you don’t already have it. With GitHub Desktop, you get a command line version of Git with a robust GUI. Regardless of if you have Git installed or not, GitHub Desktop offers a simple collaboration tool for Git. You can learn more here.
Install Git on Windows
Install Git on Mac
Install Git From an Installer
Note: git-scm is a popular and recommended resource for downloading Git on a Mac. The advantage of downloading Git from git-scm is that your download automatically starts with the latest version of Git. The download source is the same macOS Git Installer as referenced in the steps above.
Install Git from Homebrew
Homebrew is a popular package manager for macOS. If you already have Homwbrew installed, you can follow the below steps to install Git:
Install Git on Linux
Fun fact: Git was originally developed to version the Linux operating system! So, it only makes sense that it is easy to configure to run on Linux.
You can install Git on Linux through the package management tool that comes with your distribution.
Note: You can download the proper Git versions and read more about how to install on specific Linux systems, like installing Git on Ubuntu or Fedora, in git-scm’s documentation.
Other Methods of Installing Git
Looking to install Git via the source code? Learn more here.
Get started with git and GitHub
Review code, manage projects, and build software alongside 40 million developers.
derhuerst / intro.md
Installing Git – the easy way
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Choose one of the following options.
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
You can use Git now.
Red Hat-based linux systems
You can use Git now.
Homebrew […] simplifies the installation of software on the Mac OS X operating system.
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
You can use Git now.
Installing Git on Windows
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
Anthomy1 commented May 30, 2019
I need help.
I’m using Kali Linux.
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
The most current stable version of Git for Ubuntu.
For release candidates, go to https://launchpad.net/
Hope that helps someone.
virgilwashere commented Jun 4, 2019
⚠️ 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.
sagynov commented Jun 16, 2019
Knlsharma commented Jul 22, 2019
Lucifer8759 commented Jul 23, 2019
I need help.
I’m using Kali Linux.
mark-nirdesh commented Dec 17, 2019
I need help.
I’m using Kali Linux.
ocBruno commented Feb 14, 2020
Just a heads up!
The Instructions for Windows is linking to the linux instructions
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 commented Mar 31, 2020
It worked! Thank you.
gprakarsh commented Aug 10, 2020
ASCassinda commented Aug 25, 2020
Cyber-Guy24 commented Sep 3, 2020
Thanks mark-nirdesh that worked for me as well
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.
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.
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.
your laptop password, I use a macbook, I also enter my laptop password
temoke-levelops commented Nov 5, 2020
Works for Mac! Where do I give thumbs up?
mavaddat commented Dec 19, 2020
They (incorrectly) copied the entire markdown-laden code-block and pasted that into the bash terminal, which of course bash cannot interpret as a command. Do not paste the markdown (e.g., «`shell ) into bash — that part is just for formatting the code on GitHub.
AssefaDemeke12 commented Dec 26, 2020
git hub setup for linux
Poojap19create commented Mar 26, 2021
I am getting an error while installing git for UBUNTU Can anybody help please
mavaddat commented Mar 29, 2021 •
I am getting an error while installing git for UBUNTU Can anybody help please
Your Ubuntu version is no longer maintained. You need to update your distribution to a version that is within its support lifetime. For example, try using this upgrade combination: