Why can't you merge into a bare git repository?

Why can not I merge in a bare repo? Bare repos do not have a HEAD or work tree. In the configuration file, we see bare=true .

You also cannot pull in a bare repo (because pull = fetch, merge and merge do not work). However, you can click on 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 may be "how does git merge work?" Why is HEAD needed? What does he do when merged?

+4
source share
1 answer

As Chronial points out , pressing makes fast merges or forced updates that simply move the links / branch pointers to another commit.

In a real merger without fast forwarding, you need a working copy in case of conflicts that you need to resolve. This was previously mentioned by other users; for example see this answer (highlighted by me):

git performs all merge-y operations (real merges, cherries, drag and drop, patch applications) in the work tree. This is mentioned several times earlier, for example, in one of the knowledgeable answers of Yakub Narbsky:

It is not possible to merge (or rebase) a connection without touching the working directory (and index), since merge conflicts can occur that must be resolved using the working directory (and / or index) .

+1
source

Source: https://habr.com/ru/post/1499493/


All Articles