git_repository_open()上下文中“git repository folder”和“existing work dir”之间有什么区别?

时间:2014-08-23 22:28:39

标签: libgit2

docs for git_repository_open说:

  

'path'参数必须指向git存储库文件夹或现有工作目录。

“现有工作目录”究竟是什么意思?可以使用任何子文件夹吗?详细的解释或示例会非常有用。

1 个答案:

答案 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