Why can’t I merge
into a bare repo? Bare repos don’t have a HEAD
or a working tree. In the config file we can see bare=true
.
You also can’t pull
in a bare repo (because pull = fetch & merge and merge doesn't work). However, you can push to a bare repo – why? As far as I know, push
also contains a merge, but in this case we can do it well.
So, the question could be “how does git merge work?”. Why does it need a HEAD
? What is it doing when merging?
As Chronial points out, pushing does fast-forward merges or forced updates, which just moves references/branch pointers to a different commit.
In an actual non-fast-forward merge, you need a working copy in the case that you get conflicts that you need to resolve. It's been mentioned before by other Stack Overflow users; for example, see this answer (emphasis mine):