简体   繁体   中英

Get unpushed commits with libgit2

Is there a way to show all unpushed commits from all available branches with libgit 2. My idea was to use git_revparse(&spec, repo, "origin/master..master"); but this gives me a git_revspec and I don't know how to use this to iterate over all commits. Another problem is that this method is for a specific branch only.

Use the git_branch_iterator functions to get all of the local branches and git_branch_upstream to get their corresponding upstream branch. Then use the git_revwalk functions to walk over all of the commits that are different between them. Push the upstream with git_revwalk_push_ref and hide the local branch with git_revwalk_hide_ref .

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