0

Background:

I've created a bare repo

cd ~  
git init --bare GitDrive  

The idea was to use this as the git dir for google drive

cd "Google Drive"  
echo "gitdir: ../GitDrive  

But git didn't like this until I removed bare = true from .git/config

This got me thinking about the purpose of having a configuration setting whether a repo is bare or not.
Reading git-config it appears to be used to avoid having to guess whether a repo is bare or not.

I know you can't checkout in a bare repo but you can't checkout in a repo/.git/ either regardless of the config.bare setting.

In what situations can't git determine whether a repo is bare or not?

What is the technical term for the directory containing the files config/info/hooks/index...?
Being repo/ for a bare repo and repo/.git/ otherwise.

What is the technical difference between a repo created using git init --bare and pulling the .git directory out of a live repo?

rubenvb
  • 74,642
  • 33
  • 187
  • 332
hultqvist
  • 17,451
  • 15
  • 64
  • 101
  • You started digging into files and you didn't tell what exactly do you want to achieve. You said something about "Google Drive". How do you want to use `git` related to "Google Drive"? – axiac Jan 16 '15 at 11:50
  • @axiac "Google Drive" is not the issue, it has been solved using the solution described in the first part of the question, the *Background*. What I've achieved is to have the synchronized Google Drive folder under git version control without storing the .git folder inside the synchronized folder(because nowadays .git is not ignored anymore). **still this is not what the question is about** – hultqvist Jan 16 '15 at 14:44

2 Answers2

1

A bare repository is not associated with any working directory at all. Its purpose is to accept pushes from other repositories. A non-bare repository has a working directory, which is the parent directory of the .git folder. Although non-bare repositories can technically be pushed to, it is not advisable because if you are pushing to the current branch of the non-bare repository, it can cause issues with the working directory and index since they might not be merged correctly.

A bare repository can have a current branch, but when you check out branches there is no effect except to the HEAD file. The purpose of this is to browse using Git commands. No direct view of the file structure is available.

Joseph K. Strauss
  • 4,683
  • 1
  • 23
  • 40
  • 1
    *[...] which is the parent directory of the .git folder.* That's true in most cases, but not necessarily. – jub0bs Jan 14 '15 at 14:32
  • It's a good start describing the general concepts of bare vs non-bare repos but it stops where my question starts. – hultqvist Jan 16 '15 at 11:14
0

Your question is not clear; if the goal is to put the files you have on the directory Google Drive in a git repository that is located outside the Google Drive directory then the solution is very simple:

cd "Google Drive"
git init --separate-git-dir ../GitDrive

Make sure the directory ../GitDrive does not already exists or it is empty.

This way git will create the repository in directory ../GitDrive instead of ./.git (inside the current directory). It will create, however, a file named .git in the working tree (the "Google Drive" directory) that contains the path of the repository (the complete path to ../GitDrive).

You can run your git commands both in Google Drive and in GitDrive, they will work (the repository also knows where the working tree is). But you have no real reason to mess around with files in the repository. Do your work in the working tree (directory Google Drive), as usual.

axiac
  • 68,258
  • 9
  • 99
  • 134
  • Thanks that good to know, it's like a shortcut(if you remember the command) to what I did in the *Background* part of my questions. Though it does not seem to address the questions stated in the end. – hultqvist Jan 16 '15 at 14:47
  • It is not a shortcut, it is the correct way to do it :-) – axiac Jan 16 '15 at 15:05
  • You can find some information on [`git`s documentation](http://git-scm.com/docs/gitrepository-layout) about the differences. You can read [this article](http://bitflop.com/tutorials/git-bare-vs-non-bare-repositories.html), it explains some things. Also this SO question: [How to convert a normal Git repository to a bare one?](http://stackoverflow.com/questions/2199897/how-to-convert-a-normal-git-repository-to-a-bare-one) – axiac Jan 16 '15 at 15:06