docs for git_repository_open说:
'path'参数必须指向git存储库文件夹或现有工作目录。
“现有工作目录”究竟是什么意思?可以使用任何子文件夹吗?详细的解释或示例会非常有用。
答案 0 :(得分:0)
在freenode上的#libgit2中由cmn_回答:
<cmn_> shurcooL: you're right, I was thinking of git_repository_discover()
<cmn_> which *will* take any of those paths and give you the right one
<cmn_> shurcooL: what you usually call a "git repository" is two things, the gitdir and the worktree; the worktree is where you files live (and the top-level has the .git), and the gitdir is where git stores its data
<cmn_> what it's telling you is that if you have someproject/ and someproject/.git you can pass either of those paths and libgit2 will load the repository; the former being the worktree/workdir and the latter the repository