# Cannot push Git commits by LibGit2

**URL:** <https://discourse.julialang.org/t/cannot-push-git-commits-by-libgit2/104076>\
**Category:** General Usage\
**Created:** [September 20, 2023, 6:24pm UTC](https://discourse.julialang.org/t/cannot-push-git-commits-by-libgit2/104076 "2023-09-20T18:24:20Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![wsshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsshin/32/360_2.png) [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Post date:** [September 25, 2023, 4:29am UTC](https://discourse.julialang.org/t/cannot-push-git-commits-by-libgit2/104076/8 "2023-09-25T04:29:23Z")

</div>

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](https://discourse.julialang.org/t/local-registry-rsa-key-problem/78188/5), 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

```julia
LibGit2.push(repo; refspecs=["refs/heads/main"])

```

where `main` in `"refs/heads/main"` is my Git branch name to push.

---

_[View the full topic](https://discourse.julialang.org/t/cannot-push-git-commits-by-libgit2/104076)._
