Bare Git, libgit2sharp question

Does anybody have experience with libgit2sharp and/or bare git repos?

I tried to create a git repo to track some files but always get a detached HEAD and I cannot figure out what I’m doing wrong.

Any ideas?

I thought that a bare git repository by definition is just a copy of the repository (so you don’t have a working copy) and thus not a branch you’re working on.

Yes, there is no working copy. But when I now clone the bare git, it should produce a proper git with the working copy (it creates the working copy by going through the commits).
When I clone my bare git, I get a warning regarding detached HEAD.

I also did create a normal git using git commands (not libgit2sharp) and created a bare repo out of it. The difference between my bare repo and the one I created via git commands was that my repo was not connected to the master branch.

That’s because you checkout a commit, not a branch. Commits are detached, branches are not. If you want a specific branch:
git checkout -b mybranch abcdef

However when you push a commit on top of non-top revision it will fail (without a git pull first)

maybe I do not understand it properly, but it appears like my commit are not assigned to any branch.

Commits usually aren’t, since a specific commit can be in multiple branches. You should checkout a branch, not a commit. If your purpose is to just read from a past commit, then the detached HEAD is not a problem.

I see that I can recreate the complete source from the commits, so it’s not necessarily a problem.

But, in my repo, the commits are not assigned to any branch, I cannot clone a branch (or checkout). I can only clone the complete thing, there no branches or so. it’s like I lose what the head originally pointed to when the repo got created.

It looks different than when I do it using normal git and crate a bare git out of it.

gitk shows no branches, just the linked commits.

Do I need to create the master branch? Isn’t it there by default? (As the Tip is empty and the branches, too)

The real question is: do you really need a branch? If you’re not going to change anything, a detached commit is perfectly fine.