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 .