Tutorial

How To Install Git on FreeBSD 11.0

Published on November 23, 2016
Default avatar

By Steve Russo

How To Install Git on FreeBSD 11.0
Not using FreeBSD 11?Choose a different version or distribution.
FreeBSD 11

Introduction

Version control systems are an indispensable tool in modern software development. They allow you to keep track of your software at the source level. You can track changes, revert to previous stages, and branch to create alternate versions of files and directories.

Git is one of the most popular distributed version control systems. Many projects maintain their files in a Git repository, and sites like GitHub and Bitbucket have made sharing and contributing to code simple and valuable.

In this guide, we will demonstrate how to install and configure Git on a FreeBSD 11.0 server. We will cover how to install the software in two different ways, each of which has its own benefits.

Note: As of July 1, 2022, DigitalOcean no longer supports FreeBSD Droplets through the Control Panel or API. However, you can still spin up FreeBSD Droplets using a custom image. Learn how to import a custom image to DigitalOcean by following our product documentation.

Prerequisites

To follow this tutorial, you will need:

  • One FreeBSD 11 server with a root user. For the purposes of this tutorial, the user is referred to as freebsd.

A FreeBSD server requires an SSH key for remote access. For help on setting up an SSH key, read How To Configure SSH Key-Based Authentication on a FreeBSD Server. To learn more about FreeBSD servers and basic management, check out the Getting Started with FreeBSD tutorial series.

Installing Git via Packages

The first installation method we’ll show uses the FreeBSD package index. This is generally the easiest and fastest way to install Git.

First, update the pkg repository index.

  1. sudo pkg update -f

Next, download and install the git package.

  1. sudo pkg install git

You’ll need to enter y to confirm the installation. That’s it!

You can now move on to the Configuring Git section below to see some basic, useful customization options.

Installing Git via Ports

The FreeBSD ports system is another way of manging applications on a FreeBSD server. It’s managed through a filesystem hierarchy called the ports tree, located at /usr/ports, which categorizes each available piece of software that FreeBSD knows how to build. portsnap is a tool that comes with FreeBSD and simplifies working with the ports tree. You can learn more in this ports on FreeBSD tutorial.

Install Git via ports will take longer than installing it via packages, as you will be building it and several dependencies from source (rather than downloading precompiled binaries, as you would do with pkg). The benefit of using ports is a higher level of customization.

First, if you haven’t already, download and extract the ports tree files into /usr/ports. This may take a while, but you only ever have to do it once.

  1. sudo portsnap fetch extract

If you already have the ports tree downloaded, instead you should update it with:

  1. sudo portsnap fetch update

Then, move to the devel/git directory in the ports tree.

  1. cd /usr/ports/devel/git

Finally, build Git. Including BATCH="yes" in this command will install the Git port quietly and avoid the many dialogs along the way asking which parts of certain software you would like installed. You can omit this if you would like to be prompted for which components of each port to install; hitting ENTER will assume the default.

  1. sudo make install clean BATCH="yes"

Now that Git is installed, we can configure it.

Configuring Git

First, let’s view the existing Git configuration settings. These are pulled from the ~/.gitconfig file.

  1. git config --list

From here, you can update any settings you’d like. For example, update your username with the following command replacing sammy with your username.

  1. git config --global user.name "sammy"

You can update your email address with this command, replacing sammy@example.com with your email address.

  1. git config --global user.email "sammy@example.com"

Specify your default text editor by replacing vim below with your preferred text editor.

git config --global core.editor "vim"

You can check that your updates went through by looking at your configuration settings again.

  1. git config --list
Output
user.name=sammy user.email=sammy@example.com core.editor=vim

Conclusion

You should now have Git installed on your FreeBSD 11.0 server. For more information on Git, check out the following tutorials:

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors
Default avatar
Steve Russo

author


Default avatar

staff technical writer

hi! i write do.co/docs now, but i used to be the senior tech editor publishing tutorials here in the community.


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
Leave a comment


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel