# LibGit2 question

**URL:** <https://discourse.julialang.org/t/libgit2-question/87871>\
**Category:** General Usage\
**Tags:** question, libgit2\
**Created:** [September 27, 2022, 1:46pm UTC](https://discourse.julialang.org/t/libgit2-question/87871 "2022-09-27T13:46:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 27, 2022, 1:46pm UTC](https://discourse.julialang.org/t/libgit2-question/87871/1 "2022-09-27T13:46:07Z")

</div>

The library LibGit2 is part of Julia, I think.

How can I achieve the aquivalent of:

```julia
git diff --name-only --cached

```

using LibGit2?

I tried:

```julia
    repo = LibGit2.GitRepo(".")
    LibGit2.diff_files(repo, "main", "origin/main")

```

which does not work (it returns an empty AbstractString).

Any idea?

I just want to get a list of staged files.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [September 27, 2022, 2:15pm UTC](https://discourse.julialang.org/t/libgit2-question/87871/2 "2022-09-27T14:15:26Z")

</div>

If you only want to use LibGit2 in order not to rely on an external git being available on the system, you might prefer to use the `Git` package instead:

```julia
using Git
git = Git.git()
staged_files = readlines(`$git diff --name-only --cached`)

```

Whether it can be done with LibGit2 I have no idea though.
