OneGen Blog


How to install git2go on Rocky Linux

Published: December 14, 2022

This guide will show you how to install git2go including the underlying libgit2 library on Rocky Linux.

git2go is a binding library that makes it easy to work with libgit2 in golang. It requires to install the underlying libgit2 library as well.

1. Install git2go

  • First go to the git2go's github repository
  • Scroll down until you see the version table that looks like this: git2go version table
  • This versioning table maps a git2go version to a libgit2 version. You probably want to use the newest git2go version. At the time of writing the article, it'd be v34, which corresponds to libgit2 1.5.
  • Install git2go by (replace the v34 with your version): $ go get
  • Import git2go in your app: import ""

2. Install Dependencies

You'll need to install the following dependencies. We use Rocky Linux, so if you're on another distro, the installation might be slightly different.

$ sudo dnf group install "Development Tools"
$ sudo dnf install wget pkgconfig cmake

3. Install libgit2

libgit2 is a library that implements all the core functions of git.

  • Go to the libgit2 website
  • Click on Download and select the version based on the git2go's version table
  • Download it with wget: $ wget copied_url_to_targz_package
  • Unpack the lib2git using: $ tar -xvf libgit2_package_path
  • Move inside the extracted libgit2 directory
  • Create the build directory: $ mkdir build && cd build
  • Run cmake: $ cmake ..
  • Build and install libgit2 on your system: $ sudo cmake --build . --target install

Try to compile your golang app. If you see a libgit2 or pkg-config error, please follow the instructions below.

Can't find libgit2 or pkg-config

The sudo cmake --build . --target install command you ran earlier printed out where it placed the library on your system, for instance, on Rocky Linux 8 it is /usr/local/lib64.

  • Open your bash profile: $ vim ~/.bash_profile
  • Export the following env variables at the end of the file. Use the path from above.
    export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
    export LD_LIBRARY_PATH=/usr/local/lib64
  • Save & close the file (by typing :wq)
  • Activate changes: $ source ~/.bash_profile

You're all set! Your golang app should compile just fine.

We use cookies to track activity using Google Analytics & reCAPTCHA. It helps us understand what our visitors like about our product and how they interact with our website. For more information, check out our Privacy Policy.