What is a bare repository and why would I need one?
<p>This maybe has been answered, but I didn't find a good answer.<br />
I come from centralized repositories, such as SVN, where usually you only perform checkouts, updates, commits, reverts, merges and not much more.</p>
<p>Git is driving me crazy. There are tons of commands, but the most difficult to understand is why many things work as they do.</p>
<p>According to <a href="http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/" rel="noreferrer">&quot;What is a bare git repository?&quot;</a>:</p>
<blockquote>
<p>Repositories created with <code>git init --bare</code> are called bare repos. They are structured a bit differently from working directories. First off, <em>they contain no working or checked out copy of your source files.</em><br />
…<br />
A bare repository created with <code>git init --bare</code> is for… <strong>sharing</strong>. …developers will clone the shared bare repo, make changes locally in their working copies of the repo, then push back to the shared bare repo to make their changes available to other users.<br />
– Jon Saints, <a href="http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/" rel="noreferrer">http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/</a></p>
</blockquote>
<p>However, from the accepted answer to <a href="https://stackoverflow.com/a/20855207">&quot;what's the difference between github repository and git bare repository?&quot;</a>:</p>
<blockquote>
<p>Git repos on GitHub are bare, like any remote repo to which you want to push to <em>[sic]</em>.<br />
– VonC, <a href="https://stackoverflow.com/a/20855207">https://stackoverflow.com/a/20855207</a></p>
</blockquote>
<p>However, in GitHub there are source files. I can see them. If I create a bare repository, there are no source files, only the contents for <code>.git</code> directory of a working repository.</p>
<p>How is this possible? What don't I understand?</p>
<p>Can you give an example about why I would need a bare repository and its motivation to work that way?</p>
<h2>UPDATE</h2>
<p>Edward Thomson's answer is, in part, what I wanted to know. Nevertheless, I will rephrase my question:</p>
<p>First link I posted states(<a href="http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/" rel="noreferrer">&quot;What is a bare git repository?&quot;</a>):</p>
<blockquote>
<p>they [bare repositories] contain no working or checked out copy of your source files.</p>
</blockquote>
<p>VonC's answer:</p>
<blockquote>
<p>Git repos on GitHub are bare</p>
</blockquote>
<p>Both statements implies</p>
<blockquote>
<blockquote>
<p>Github has no working copy.</p>
</blockquote>
</blockquote>
<p>Edward Thomson says:</p>
<blockquote>
<p>it renders the web page based on the data as you navigate through it - pulling the data directly out of the repo and out to your web browser, not writing it to a disk on the fileserver first</p>
</blockquote>
<p>Somehow, a bare repository has to contain all data and source code. If not, it wouldn't be impossible to render anything, because I can see all source code updated (commited), all branches (with their respective source), the whole log of a repo, etc.</p>
<p>Is there the whole data of a repository always within .git directory (or in a bare repo), in some kind of format which is able to render all files at any time? Is this the reason of bare repository, while working copy only has the files at a given time?</p>