Git.jl allows you to use command-line Git in your Julia packages. You do not need to have Git installed on your computer, and neither do the users of your packages!
Git.jl provides a Git binary via Git_jll.jl. The latest version of Git.jl requires at least Julia 1.6.
Git.jl is intended to work on any platform that supports Julia, including (but not limited to) Windows, macOS, Linux, and FreeBSD.
julia> using Git julia> run(`$(git()) clone https://github.com/JuliaRegistries/General`)
This can equivalently be written with explicitly split arguments as
julia> run(git(["clone", "https://github.com/JuliaRegistries/General"]))
to bypass the parsing of the command string. Of course, one can also do
julia> import Git julia> const git = Git.git() julia> run(`$git clone https://github.com/JuliaRegistries/General`)
This is thread-safe since
Cmd objects are not stateful. However, note that the
git command object won't notice any changes to environmental variables
GIT_CURL_VERBOSE for example) since it was created.
To read a single line of output from a git command you can use
julia> cd("General") julia> readchomp(`$(git()) remote get-url origin`) "https://github.com/JuliaRegistries/General"
readlines for multiple lines.
julia> readlines(`$(git()) log`)
16 days ago