Hacker News new | past | comments | ask | show | jobs | submit login

Here's the very short answer:

A bare repo has only Git's own data structure files. It's basically the contents of a non-bare repo's ".git/" directory, without a checked out working copy of all the files that are contained in the repo. The files are all still there but stored inside Git's database and not in the filesystem in the normal way.

The advantage: you can push commits to a bare repo. It's the kind of repo you'd put on your remote dev server. If you try to push to a non-bare repo, you'd get an error message like:

  remote: error: refusing to update checked out branch: refs/heads/dev
  remote: error: By default, updating the current branch in a non-bare repository
  remote: is denied, because it will make the index and work tree inconsistent
  remote: with what you pushed, and will require 'git reset --hard' to match
  remote: the work tree to HEAD.
...which is a long way of saying "don't do that". The disadvantage is that you can't cd into a bare repo and use "ls" and friends to browse around.

So here's the even shorter answer:

Make a bare repo when you only want to push to it but not work inside it, say because you're making a shared repo for you and your friends to work on together.

Make a non-bare repo when you want to work inside it but not push to it, say because it's a project you're developing on your laptop.




This is as short as I can make my understanding of what you are saying:

A bare git repo is a server side git repo while non-bare is client side.


Nailed it.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: