Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between github repository and git bare repository?

Tags:

git

github

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?

like image 544
Charles0429 Avatar asked Dec 31 '13 09:12

Charles0429


People also ask

Is GitHub a bare repository?

You can think of the Git repositories hosted on GitHub or GitLab as bare repositories, as no local development happens directly on the GitHub or GitLab servers. These are bare Git repos whose sole purpose is to enable the distributed sharing of code.

What's the difference between a bare and non-bare Git repository?

A bare repository is one that contains nothing but the . git folder; in other words, it has the index but lacks the actual working files. A non-bare repository is what you're used to working with, which includes both the git index and the checked out copy of working files.

What is a Git bare?

A bare Git repository is typically used as a Remote Repository that is sharing a repository among several different people. You don't do work right inside the remote repository so there's no Working Tree (the files in your project that you edit), just bare repository data. And that's it.

Is there a difference between Git and GitHub?

what's the difference? Simply put, Git is a version control system that lets you manage and keep track of your source code history. GitHub is a cloud-based hosting service that lets you manage Git repositories. If you have open-source projects that use Git, then GitHub is designed to help you better manage them.


2 Answers

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.

like image 130
VonC Avatar answered Sep 21 '22 14:09

VonC


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.

like image 38
janos Avatar answered Sep 21 '22 14:09

janos