Install a custom version of git

Overview

git is installed on all DreamHost servers by default, but if you'd like to run the most recent version, you are able to install it locally under your username. This article walks you through how to install a custom version of git that your Shell will use when you log in via SSH.

Install git

  1. Log into your DreamHost server via SSH.
  2. Visit the Linux downloads page.
  3. There is a link in the first paragraph to the most recent version. Right-click this and choose Copy Link Address.
  4. Make sure you're in your user's home directory.
    [server]$ cd ~
  5. Run the following command to download git.

    Change the version to the link you copied.

    [server]$ wget  https://www.kernel.org/pub/software/scm/git/git-2.34.1.tar.gz
  6. Decompress the file.
    [server]$ tar -zxf git-2.34.1.tar.gz

    This creates a new directory named after the version number.

  7. Change into this new directory.
    [server]$ cd git-2.34.1
  8. Run the following commands one at a time to install. Make sure to change the username to your SSH user.
    [server]$ make prefix=/home/username/local all
    [server]$ make prefix=/home/username install
    [server]$ exec bash
  9. Run the following command to confirm the new version of git is being used.
    [server]$ git --version

Update your .bash_profile

Now that git is installed, you should update your .bash_profile to automatically load it when you log into your server via SSH.

  1. Log into your server via SSH.
  2. Edit the .bash_profile file to add the following line.
    [server]$ export PATH=$HOME/local/bin:$PATH

When you log into your server in the future, the new version of git will load automatically.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?