简体   繁体   English

使用libgit2获得未推送的提交

[英]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"); 有没有办法用libgit 2显示所有可用分支中所有未推送的提交。我的想法是使用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. 但这给了我一个git_revspec,我不知道如何使用它来遍历所有提交。 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. 使用git_branch_iterator函数获取所有本地分支,并使用git_branch_upstream获取其相应的上游分支。 Then use the git_revwalk functions to walk over all of the commits that are different between them. 然后使用git_revwalk函数遍历它们之间所有不同的提交。 Push the upstream with git_revwalk_push_ref and hide the local branch with git_revwalk_hide_ref . 推动上游git_revwalk_push_ref和隐藏与当地分部git_revwalk_hide_ref

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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