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?
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.
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.