Install git for linux

Installing Git

To begin contributing to GitLab projects, you must install the appropriate Git client on your computer. Information about installing Git is also available at the official Git website.

Supported operating systems

macOS

A version of Git is supplied by macOS. You can use this version, or install the latest version of Git on macOS by downloading it from the project website. We recommend installing Git with Homebrew. With Homebrew, you can access an extensive selection of libraries and applications, with their dependencies managed for you.

  • 15 GB of available disk space for Homebrew and Xcode.
  • Extra disk space for any additional development libraries.

Open a terminal and install the XCode Command Line Tools:

In a terminal, verify that Git works on your computer:

Periodically you may need to update the version of Git installed by Homebrew. To do so, open a terminal and run these commands:

brew update brew upgrade git 

To verify you are on the updated version, run git —version to display your current version of Git.

Ubuntu Linux

Open a terminal and run these commands to install the latest Git from the officially maintained package archives:

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

To verify that Git works on your computer, run:

Periodically it may be necessary to update Git installed. To do so, run the same commands.

Windows

Go to the Git website, and then download and install Git for Windows.

After you install Git

After you successfully install Git on your computer, read about adding an SSH key to GitLab.

Help & feedback

Docs

Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.

Product

Create an issue if there’s something you don’t like about this feature.
Propose functionality by submitting a feature request.
Join First Look to help shape new features.

Feature availability and product trials

View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.

Get Help

If you didn’t find what you were looking for, search the docs.

If you want help with something specific and could use community support, post on the GitLab forum.

For problems setting up or using this feature (depending on your GitLab subscription).

Читайте также:  Функции управления сетью linux

Источник

Установка Git в Ubuntu

Система контроля версий — это незаменимая вещь при совместной разработке программного обеспечения. Такие программы позволяют отслеживать изменения в вашем исходном коде и при необходимости восстанавливать прошлое состояние.

Одной из самых популярных систем управления версиями заслуженно считается Git. Многие проекты хранят свои файлы в репозиториях Git, а сайты GitHub и Bitbucket сделали обмен исходным кодом очень простым. В этой небольшой статье будет рассмотрена установка Git в Ubuntu. Мы рассмотрим два способа установки, а также начальную конфигурацию.

Установка Git с помощью пакетного менеджера

Самый простой способ установить Git в Ubuntu 20.04 или других версиях, это использовать пакетный менеджер apt и официальные репозитории Ubuntu. Это самый быстрый и простой метод, но вы получите не самую свежую версию.

Для установки Git с помощью пакетного менеджера. сначала обновим списки пакетов из репозиториев:

Затем осталось загрузить и установить программу:

После этого программа будет установлена и вы можете переходить к ее настройке. Для просмотра версии выполните:

Установка Git из исходных кодов

Более гибкий, но в то же время самый сложный способ установки Git в Ubuntu — это сборка из исходных кодов. Процесс установки займет больше времени, но вы получите больше контроля над параметрами программы, а также сможете установить самую последнюю версию.

Перед тем, как приступить нам нужно будет скачать пакеты, от которых зависит Git. Все есть в официальном репозитории, поэтому вы можете все сделать с помощью пакетного менеджера:

sudo apt update
sudo apt install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

После того как все будет установлено вы можете скачать архив с самыми последними версиями исходного кода. Это можно сделать на странице релизов. Здесь есть как rc релизы, так и стабильные версии.

Когда выберите версию, нажмите кнопку Download zip. Или же скопируйте ссылку чтобы скачать с помощью терминала. Например, на данный момент самая последняя версия — 2.10.1. Вы можете использовать адрес файла вместе с wget, чтобы скачать исходники:

wget https://github.com/git/git/archive/v2.28.0.zip -o git.zip

Распакуйте только что загруженный файл с помощью unzip и переместитесь в каталог с файлами архива:

Дальше переходим к сборке программы и ее установке:

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, чтобы с программой можно было работать.

Читайте также:  Linux apt cache clean

Настройка Git в Ubuntu

После того как установка Git Ubuntu будет завершена одним из выше перечисленных способов, вам нужно еще кое-что сделать перед тем, как вы сможете полноценно работать. Вам нужно идентифицировать себя указав имя пользователя и адрес электронной почты.

Самый простой способ это сделать — с помощью команды git config. Git использует имя пользователя и Email при каждом коммите, так что задавать их обязательно. Для этого выполните команды:

git config —global user.name «Your Name»
git config —global user.email «youremail@domain.com»

Вы можете посмотреть установленные параметры с помощью команды:

Вся информация хранится в вашем конфигурационном файле Git, поэтому вы можете отредактировать его вручную если это необходимо с помощью текстового редактора:

[user]
name = Имя
email = youremail@domain.com

Здесь можно установить много других параметров, но именно эти два самые важные, потому что если вы попытаетесь что-то сделать когда они не установлены, то увидите предупреждение:

Выводы

Теперь вы знаете как выполняется установка Git Ubuntu 20.04. Мы рассмотрели два способа — простой и быстрый, а также сложный, но более гибкий. Если у вас остались вопросы спрашивайте в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

1.5 Getting Started — 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. Since Git is quite excellent at preserving backwards compatibility, any recent version should work just fine. 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.

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 macOS. 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.

Читайте также:  Открыть терминал alt linux

Git macOS installer

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:

$ sudo dnf install dh-autoreconf curl-devel expat-devel gettext-devel \ openssl-devel perl-devel zlib-devel $ sudo apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev \ gettext libz-dev libssl-dev

In order to be able to add the documentation in various formats (doc, html, info), these additional dependencies are required:

$ sudo dnf install asciidoc xmlto docbook2X $ sudo apt-get install asciidoc xmlto docbook2x

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:

$ sudo apt-get install install-info

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:

$ sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

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/tags. 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.

$ tar -zxf git-2.8.0.tar.gz $ cd git-2.8.0 $ make configure $ ./configure --prefix=/usr $ make all doc info $ sudo make install install-doc install-html install-info

After this is done, you can also get Git via Git itself for updates:

$ git clone https://git.kernel.org/pub/scm/git/git.git

Источник

Оцените статью
Adblock
detector