I found a solution. First, in order to use LibGit2, I had to have a properly generated SSH private–public key pair. I describe the procedure here, which is hugely helped by @GunnarFarneback’s analysis on the LibGit2-related issue.
Then, I was able to push commits to the remote Git hosting service simply by
LibGit2.push(repo; refspecs=["refs/heads/main"])
where main
in "refs/heads/main"
is my Git branch name to push.