Introduction

Git is one of the most used version control systems. It allows you to keep track of your software at the source level. Control changes, revert stages and create other files and directories.

In this article you’ll learn how to install Git on your FreeBSD 11.0.

Prerequisites

To follow this tutorial, make sure you have: A FreeBSD 11 server with a user with root privileges.

Installing Git on FreeBSD 11.0 via Packages

This is a simpler way to install Git on FreeBSD 11.0 and it follows a method that uses the FreeBSD package index.

The first step is to update the pkg repository index:

$

sudo pkg update -f

Then, use the following command to download and install the git package:

$

sudo pkg install git

The installation is done! But, before moving on to the configuration part, let’s see another way to install Git on FreeBSD 11.0.

Installing Git on FreeBSD 11.0 via Ports

An alternative to the above installation process is to install Git using the FreeBSD 11.0 ports system. The port system allows the management of application on FreeBSD. It is located at /usr/ports and follows a filesystem hierarchy known as ports tree. Also, portsnap is a tool that can help working with the ports tree.

Besides this process will take more time than installing with the packages, it allows more customization in the installation process.

To start, download the ports tree file and extract it to /usr/ports.

$

sudo portsnap fetch extract

After installing the ports, update it with the command below:

$

sudo portsnap fetch update

Move to the devel/git directory, which is in the ports tree:

$

cd /usr/ports/devel/git

Next step is to include BATCH=”yes” at the end of the following command to decrease the number of dialogs along the installation.

$

sudo make install clean BATCH="yes"

Git is now installed, so you can go to the configuration step.

Configuring Git on FreeBSD 11.0

To start the configuration of Git on FreeBSD you will start viewing the existing settings. This can be done with the command:

$

git config --list

From the existing settings, you can start to update it according to your preferences. Changing your username, for example, can be done with the following command:

$

git config --global user.name "ana"

Just don’t forget to replace the red part with your new username.

Also, you can change the email with the command:

$

git config --global user.email "ana@example.com"

Choose your default text editor by replacing the red part in the following code:

$

git config --global core.editor "text_editor"

Finally, check all your updates by opening the settings again:

$

git config --list

Conclusion

Now that Git is installed and configured, you can use it on your FreeBSD 11.0 server.

If you have questions about this tutorial, leave a comment below.