As I understand it, the
bare repository is created as a buffer between the main copy on the server and the development branches.
But I don’t fully understand, reading the article “successful branching model “, why this type of repository is needed if everything should work and so on.
Answer 1, authority 100%
bare repository is not some special type of repository. this is actually the repository .
git init --bare creates the repository in the current directory:
$ git init --bare $ ls -F branches / config * description HEAD hooks / info / objects / refs /
and with the
git init command (without the
--bare option) the repository is created in the
$ git init $ ls -F .git branches / config * description HEAD hooks / info / objects / refs /
which allows the current directory to be used as a working dir (working dir ) with checked out files / directories from the repository, the versions of which are tracked by this repository (in general, the working directory can be located in a completely different place and specified to the git program using the
--work-tree options, or a combination of both (these options are not equivalent), or the
GIT_WORK_TREE environment variable, or the
core.worktree config variable).
“turning” bare into non-bare (and vice versa) is very easy: just change the value (
false ) of the
bare variable in the
[core] section of the
config file. manually or with the
git config core.bare value command. that is, in fact, this is some kind of sign, which in practice means that “there is a working directory with monitored files nearby.”
why is this feature needed?
so that when trying to “push” into the current branch (the one pointed to by the contents of the
HEAD file) a “repository with a working directory” (non-bare repository) the user was getting error and detailed explanation:
remote: error: refusing to update checked out branch: refs / heads / master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require ‘git reset –hard’ to match
remote: error: the work tree to HEAD.
remote: error: You can set ‘receive.denyCurrentBranch’ configuration variable to
remote: error: ‘ignore’ or ‘warn’ in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless yo
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: To squelch this message and still keep the default behavior, set
remote: error: ‘receive.denyCurrentBranch’ configuration variable to ‘refuse’
my free translation:
Refused to update the
refs / heads / masterbranch from which the files were checked out into the working directory.
By default, updating the current branch in a non-bare repository is prohibited, because this will result in a mismatch between what you push and the index and contents of the working directory, and will require
git reset --hardto bring the working directory into line with the current branch, i.e. the one specified in the
you can set the value of the
receive.denyCurrentBranchconfig variable of the remote repository to
warnto allow push to its current branch; however, this is not recommended unless you have configured (automatic) updating of the working directory in some other way.
You can disable the issuance of this message without changing the default behavior by setting the variable
Answer 2, Authority 18%
If briefly, the BARE is the repository on the server. But Git (unlike SVN) decentralized, and servers can be as much as you like. Even on one machine.