15

In github repository, we can git push git pull operations, at the same time, we can commit to the repository through the web UI. It seems that the github repository works as bare repository and working repository at the same time?

However, in git bare repository, we cannot commit directory to the repository.

So, my question is

What's real difference between github repository and git bare repository?

Charles0429
  • 1,406
  • 5
  • 15
  • 31

3 Answers3

17

It seems that GitHub repository can work as working repository and bare repository at the same time, does that mean GitHub repository is developed from git bare repository

No, Git repos on GitHub are bare, like any remote repo to which you want to push.

Their web interface shows you a representation of the git repo content, and they might a temporary working tree to modify files directly from the web UI (for their inline edit introduced initially in 2011), but it is their own internal mechanism.
From a client's perspective, you can see those as classic bare repos.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Are all remote repo bare repo? Can non-bare repo be remote? – Boon Aug 24 '15 at 20:51
  • @Boon since recent git versions (Git 2.3+, Feb. 2015), yes, a non-bare repo can be a remote one. See http://stackoverflow.com/a/28262104/6309. And pushtodeploy git 2.4: http://stackoverflow.com/a/30030236/6309 – VonC Aug 24 '15 at 20:53
3

GitHub is a 'social website' that allows users to host their source code there. It gives you multiple ways to edit your source code:

  • Edit directly using a web interface
  • Push updates with git push
  • Commit changes with svn integration svn commit
  • ... (maybe more that I don't know of)

Depending on your perspective, you could make all kinds of guesses here:

  • If you only edit files using the web interfaces, it may seem you're editing files in a non-bare repo
  • If you only push and pull using git commands, it may seem you're talking to a bare git repo at the other end
  • If you only use Subversion commands, it may seem you're talking to a Subversion repo at the other and
  • If you aware of all these at the same time, then you can guess that all the different methods of access boil down to the same common internal mechanism

GitHub provides lots of extra magic to hide the internal details from you. I would guess there are bare git repos at the core. The web interface could either work with a non-bare clone of the original bare repo, or it could have a working tree of the files, and using git commands in the fashion: GIT_DIR=/path/to/bare.git git somecommand. In reality, it's probably much more complicated than that.

Technically, they don't even need to be using Git repositories underneath. At the core, they could be using SomeSystemXYZ, that implements all the necessary protocols to give the appearance that you're working with a Git or Subversion repository. You can only know how a website really works by looking at their source code.

Patrick M
  • 10,547
  • 9
  • 68
  • 101
janos
  • 120,954
  • 29
  • 226
  • 236
  • but it seems that github repository can work as working repository and bare repository at the same time, does that mean github repository is developed from git bare repository, and add some other functions(like direct commit, issues and so on) on bare repository? – Charles0429 Dec 31 '13 at 09:34
  • @Charles0429 I clarified my answer – janos Dec 31 '13 at 10:08
0

This quote is taken from; Version Control with Git

Bare and Development Repositories

A Git repository is either a bare or a development (nonbare) repository. A development repository is used for normal, daily development. It maintains the notion of a current branch and provides a checked out copy of the current branch in a working directory. All of the repositories mentioned in the book so far have been development repositories. In contrast, a bare repository has no working directory and shouldn’t be used for normal development. A bare repository has no notion of a checked out branch, either. Think of a bare repository as simply the contents of the .git directory. In other words, you shouldn’t make commits in a bare repository. A bare repository might seem to be of little use, but its role is crucial: to serve as an authoritative focal point for collaborative development. Other developers clone and fetch from the bare repository and push updates to it. We’ll work through an example later in this chapter that shows how all this works together. If you issue git clone with the --bare option, Git creates a bare repository; otherwise, a development repository is created.

Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158