问题
While reading the tutorials I keep hearing that I need to create something known as a bare repository for sharing all the files in the repo.
I also hear that a bare repo does not contain any of the worfiles.
If it does not have any workfiles then what will the other users clone on their local machines???
I currently have a directory in my linux server which i need to share among several users which will be accessing through eclipse ide's.
Can anyone explain the issues highlighted above in plain words.
回答1:
While reading the tutorials I keep hearing that I need to create something known as a bare repository for sharing all the files in the repo.
When you git push
to a remote repository, you can overwrite the files in the working directory
. To avoid this, you can use a bare
repository, which doesn't even have a working directory
.
However, because there's no working directory
, you can't work in the bare
repo, you can only push
to it and pull
from it. This makes it ideal as a "collection point" or "collaboration repo" for multiple users -- which is why the git
tutorials say to use a bare
repository for servers.
A normal git
repo looks like this:
my-repository/
.git/
COMMIT_EDITMSG
ORIG_HEAD
description
index
objects
FETCH_HEAD
branches
gitk.cache
info
refs
HEAD
config
hooks
logs
file1
file2
my-repository
is the working directory
, containing the files you work on file1
, file2
etc. All the git
data is stored in the .git
folder.
On a bare
repository, you don't have a working folder. All you have is the contents of the .git
folder, stored in the top-level of that repository:
my-bare-repository/
COMMIT_EDITMSG
ORIG_HEAD
description
index
objects
FETCH_HEAD
branches
gitk.cache
info
refs
HEAD
config
hooks
logs
This is what other users clone.
回答2:
I also hear that a bare repo does not contain any of the workfiles.
Yes it is.
A remote repository is generally a bare repository — a Git repository that has no working directory. All data is stored in .git
directory and working directory is not needed. It is just a collaboration point.
If it does not have any workfiles then what will the other users clone on their local machines???
Data from .git
directory will be cloned.
来源:https://stackoverflow.com/questions/14214584/need-for-a-bare-repo-in-git