0

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.

gautam vegeta
  • 653
  • 6
  • 13
  • 28

2 Answers2

3

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.

simont
  • 68,704
  • 18
  • 117
  • 136
  • Thanks for the reply.I got the points you made.I also have another directory containing actual files which I want others to checkout.Now what do i need to do? – gautam vegeta Jan 08 '13 at 13:06
  • @gautamvegeta: (1) Commit those files to a repository. (2) Push the commit to a public repository. (3) Tell other users to clone/pull from the public repository. – Dietrich Epp Jan 08 '13 at 13:08
  • I have heard something known that I need post-receive hooks what are they and how do I set up those.Here I have heard that I can clone my actual repo containing workfiles using this post-receive hook through this bare repo. – gautam vegeta Jan 08 '13 at 13:14
  • @gautamvegeta: Please stop posting the same question in multiple places. – Dietrich Epp Jan 08 '13 at 13:16
  • @gautamvegeta This is no longer about the question - read [this book](http://git-scm.com/book). It **really** helped me learn about `git`. And it has pretty pictures. If you've got specific questions about `post-hooks` etc, ask in a separate question :) – simont Jan 08 '13 at 13:16
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.

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • What do i need to do if I want the users to check out the actual folder which has the actual contents through this bare repo. – gautam vegeta Jan 08 '13 at 13:02
  • 1
    @gautamvegeta: The method is the same for cloning from bare and non-bare repositories. Users do not need special instructions, an ordinary `git clone` works for both. – Dietrich Epp Jan 08 '13 at 13:07
  • I have heard something known that I need post-receive hooks what are they and how do I set up those.Here I have heard that I can clone my actual repo containing workfiles using this post-receive hook through this bare repo. – gautam vegeta Jan 08 '13 at 13:13
  • @gautamvegeta: Why do you need post-receive hooks? – Dietrich Epp Jan 08 '13 at 13:16
  • I got the feeling that I need to create something known as post-receive hooks which would link the bare repo and actual repo containing workfiles.So when other users would push their changes to the project it would inturn update the actaul repo. – gautam vegeta Jan 08 '13 at 13:21
  • @gautamvegeta: No, you don't need post-receive hooks. You will typically only push to bare repos, so there is no working copy to update. – Dietrich Epp Jan 08 '13 at 13:22
  • So If i want to share to the team a folder which is consisting of actaul work files how can I do it? – gautam vegeta Jan 08 '13 at 13:30
  • @gautamvegeta: This is covered in any Git tutorial. To share the contents of a folder, (1) commit the files, (2) push to a public repository, (3) ask the team to pull/clone the repository. – Dietrich Epp Jan 08 '13 at 13:34
  • @gautamvegeta: Think of these three steps as (1) save your changes (2) publish the work (3) download it. – Dietrich Epp Jan 08 '13 at 13:35
  • So what is the post-receive hook used for?May be I've mixed up a lot.Is the post-receive hook relevant at all? – gautam vegeta Jan 08 '13 at 13:38
  • I also saw a question with the subject "Post-receive hook to pull from bare repo" http://stackoverflow.com/questions/13878583/post-receive-hook-to-pull-from-bare-repo?rq=1 – gautam vegeta Jan 08 '13 at 13:41
  • @gautamvegeta: You can do anything you want in a hook. A hook is just a place for you to put a script that Git will run at a specific time. You don't need a hook, it is entirely your decision if you want a hook, and it is your decision what the hook does. – Dietrich Epp Jan 08 '13 at 13:43
  • Say If i wanted to do it this way how can I do it? – gautam vegeta Jan 08 '13 at 13:45
  • If bare reo is just a collaborating point what to what files is it collaborating to? – gautam vegeta Jan 08 '13 at 13:59