I am trying to write a script that commits changes in files and pushes them to the upstream using LibGit2
, but push()
is not working.
I am able to create a LibGit2.GitRepo
, add changes to it, and commit the changes by
repo = LibGit2.GitRepo(repo_path)
LibGit2.add!(repo, ".")
LibGit2.commit(repo, "Commit message")
git log
in the terminal confirms that the commit is correctly created with the commit message.
Then, if I attempt to push the commit by
LibGit2.push(repo)
I get the following error:
SSH host verification: the identity of the server `<URL of my organization's GitHub Enterprise>:22` does not match its known hosts record. Someone could be trying to man-in-the-middle your connection. It is also possible that the server has changed its key, in which case you should check with the server administrator and if they confirm that the key has been changed, update your known hosts file.
ERROR: GitError(Code:ERROR, Class:Net, user cancelled hostkey check)
Stacktrace:
[1] macro expansion
@ ~/pkg/julia/julia-1.9/usr/share/julia/stdlib/v1.9/LibGit2/src/error.jl:111 [inlined]
[2] push(rmt::LibGit2.GitRemote, refspecs::Vector{AbstractString}; force::Bool, options::LibGit2.PushOptions)
@ LibGit2 ~/pkg/julia/julia-1.9/usr/share/julia/stdlib/v1.9/LibGit2/src/remote.jl:324
[3] push
@ ~/pkg/julia/julia-1.9/usr/share/julia/stdlib/v1.9/LibGit2/src/remote.jl:321 [inlined]
[4] push(repo::GitRepo; remote::String, remoteurl::String, refspecs::Vector{AbstractString}, force::Bool, credentials::Nothing, callbacks::Dict{Symbol, Tuple{Ptr{Nothing}, Any}})
@ LibGit2 ~/pkg/julia/julia-1.9/usr/share/julia/stdlib/v1.9/LibGit2/src/LibGit2.jl:349
[5] push(repo::GitRepo)
@ LibGit2 ~/pkg/julia/julia-1.9/usr/share/julia/stdlib/v1.9/LibGit2/src/LibGit2.jl:325
[...]
This is odd, because I can git push
from the terminal without any issue.
I’m wondering if anyone knows a solution to this problem. The Julia version is 1.9.3.