如何使用 libgit2 库创建分支,API 引用了提交目标,但是我应该为这个参数使用什么?
这是我到目前为止得到的代码,基于测试中的示例代码,但它们使用了许多硬编码引用,因此很难发现你应该在现实世界场景中使用什么,比如我应该在这个“目标”中传递什么实例。
git_reference *branch = NULL, *head = NULL;
/* Create the branch */
git_branch_create( &branch, open_repo, "MyNewBranch", target, 0 );
/* Make HEAD point to this branch */
git_reference_symbolic_create( &head, open_repo, "HEAD", git_reference_name( branch ), 1 );
git_reference_free( head );
git_reference_free( branch );