Remove any libgit2 packages you already have, otherwise these will be included first and they do not necessarily have everything needed that you need for pygit2/git2go.
sudo apt-get purge libgit2-0 libgit2-dev
From http://www.pygit2.org/install.html
wget https://github.com/libgit2/libgit2/archive/v0.23.4.tar.gz
tar xzf v0.23.4.tar.gz
cd libgit2-0.23.4/
cmake .
make
sudo make install
If you get:
error while loading shared libraries: libgit2.so.23: cannot open shared object file: No such file or directory
Add LD_LIBRARY_PATH envionment variable for dynamically linked libraries - stackoverflow link
export LD_LIBRARY_PATH=/usr/local/lib