[英]How to get the last commit from HEAD in a git repository using libGit2Sharp?
How can I get the last Commit from the current Head? 如何从当前头部获得最后一个提交?
I guess I need to get the current Branch (repo.Head), then the SHA1 (how?) and then lookup the commit using the SHA1 (how?). 我想我需要获取当前的Branch(repo.Head),然后是SHA1(如何?)然后使用SHA1查找提交(如何?)。
I need to get the last Commit from the current Head.
我需要从当前Head获得最后一个Commit。 How can I do that?
我怎样才能做到这一点?
repo.Head
returns the current Branch
or the repository. repo.Head
返回当前Branch
或存储库。
A Branch
exposes a Tip
property which points to the latest Commit
. Branch
公开了一个Tip
属性,该属性指向最新的Commit
。
Thus: 从而:
repo.Head.Tip
will return the latest commit of the current Head
. repo.Head.Tip
将返回当前Head
的最新提交。
repo.Head.Tip.Id
the sha of this Commit
. repo.Head.Tip.Id
这个Commit
的sha。
I couldnt find a Testcase which helps me out
我找不到可以帮助我的Testcase
You can peek at this test which leverages this kind of code to retreive the sha of the latest commit of the branch pointed at by Head. 您可以查看此测试 , 该测试利用此类代码来检索Head指向的分支的最新提交的sha。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.