I have been facing difficulty in understanding the bare repository . I have read everywhere that a shared repo is a bare repo. Why must it be a bare repo? Can't it be a normal repo which collaborators clone and then push/pull?
-
possible duplicate of [What's the -practical- difference between a Bare and non-Bare repository?](http://stackoverflow.com/questions/5540883/whats-the-practical-difference-between-a-bare-and-non-bare-repository) – Ciro Santilli OurBigBook.com Dec 17 '14 at 08:04
1 Answers
It needs to be a bare repo because a not bare repo would have a working tree (meaning a specific version of that repo checked out and with files visible).
Each time you are pushing to a non-bare repo, you have no guarantee that its working tree will reflect what you are pushing, since by default said working tree will be untouched.
(Imagine if a push would trigger an update of the working tree: the files would change all of a sudden without any control from users on the receiving end)
That is why it is simpler to have a bare repo as an upstream repo (one you push to): no working tree to manage/update.
See more at "all about "bare" repos -- what, why, and how to fix a non-bare push".
It doesn't have a checked out tree, so it just does what the "server" notionally does in a centralised VCS -- records commits, branches, etc when you push to it, and gives you the latest versions when you clone or pull from it.

- 1,262,500
- 529
- 4,410
- 5,250
-
can you please explain this a bit if possible?"Each time you are pushing to a non-bare repo, you have no guarantee that its working tree will reflect what you are pushing, since by default said working tree will be untouched." – user2636464 Jun 09 '14 at 07:58
-
@user2636464 when you push new commits, the files that are currently checked out won't change. – VonC Jun 09 '14 at 08:00