简体   繁体   中英

How to list Branches using LibGit2 C++?

I am trying to create a simple User Interface using Qt, c++ and LibGit2 which displays git branches.

I've done research but cant seem to find anything that explains the process of doing this.

I am still new to C++ and git so I'm sorry in advance if you think this is a stupid question. I'm just trying to learn something new.

See the git_branch_iterator functions. For example:

git_branch_iterator *it;
if (!git_branch_iterator_new(&it, repo, GIT_BRANCH_ALL)) {
  git_reference *ref;
  git_branch_t type;
  while (!git_branch_next(&ref, &type, it)) {
    // Do something with 'ref' and 'type'.
    git_reference_free(ref);
  }
  git_branch_iterator_free(it);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM