TranslateProject/sources/tech/20200219 How to Install Latest Git Version on Ubuntu.md
2020-02-20 08:32:13 +08:00

4.5 KiB
Raw Blame History

How to Install Latest Git Version on Ubuntu

Installing Git on Ubuntu is very easy. It is available in the main repository of Ubuntu and you can install it using the apt command like this:

sudo apt install git

Easy? Isnt it?

There is only a slight little problem (which might not be a problem at all) and that is the version of Git it installs.

On an LTS system, the software stability is of upmost importance this is why Ubuntu 18.04 and other distributions often provide older but stable version of a software that is well tested with the distribution release.

This is why when you check the Git version, youll see that it installs a version which is older than the current Git version available on Git projects website:

[email protected]:~$ git --version
git version 2.17.1

At the time of writing this tutorial, the version available on its website is 2.25. So how do you install the latest Git on Ubuntu then?

Install latest Git on Ubuntu-based Linux distributions

One way would be to install from source code. That cool, old school method is not everyones cup of tea. Thankfully, there is a PPA available from Ubuntu Git Maintainers team that you can use to easily install the latest stable Git version.

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

Even if you had installed Git using apt previously, it will get updated to the latest stable version.

[email protected]:~$ git --version
git version 2.25.0

The beauty of using PPA is that if there is a new stable version of Git released, youll get it with the system updates. Just update Ubuntu to get the latest Git stable version.

Trivia

Did you know that Git version control system was created by none other than Linux creator Linus Torvalds?

If you have installed Git for development purposes, youll soon start cloning repos, make your changes and commit your change.

If you try to commit your code, you may see a Please tell me who you are error like this:

[email protected]:~/compress-pdf$ git commit -m "update readme"

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got '[email protected](none)')

This is because you havent configured Git with your personal information which is mandatory.

As the error already hints, you can set up global Git configuration like this:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

You can check the Git configuration with this command:

git config --list

It should show an output like this:

[email protected]
user.name=abhishek

This configuration is stored in ~/.gitconfig file. You may also change it manually to change the configuration.


In the end…

I hope this quick little tutorial helped you to install Git on Ubuntu. With the PPA, you easily get the latest Git version.

If you have any questions or suggestions, please feel free to ask in the comment section. A quick thank you is also welcomed :)


via: https://itsfoss.com/install-git-ubuntu/

作者:Abhishek Prakash 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出