# Setting Up a GIT Repository Mirror

3 messages from 2008-11-06 to 2008-11-07. Participants: Yaser Raja, Santi Béjar.
Thread: https://gitlist.dev/t/16199

## Yaser Raja, 2008-11-06 15:08

Subject: Setting Up a GIT Repository Mirror
Message-ID: <e97d51700811060708y5deb9e9ek4a36c012726b3a63@mail.gmail.com>
URL: https://gitlist.dev/e/e97d51700811060708y5deb9e9ek4a36c012726b3a63%40mail.gmail.com
In-Reply-To: <e97d51700811060706t40433bb9k7a3704429f244164@mail.gmail.com>

```
Hi

I have a main repository placed at a remote location and i want to
have a read-only mirror of this repository available locally. The
users/automated processes will use this local mirror to get the latest
code.

Can anyone guide me how to implement this? I did make a basic setup as
follows but it has some issues:

1. Create a clone (MirrorRep) of the remote git repository (MainRep)
on a local machine using "git-clone" command
         git-clone ssh://<user>@<remote machine addr> MyMirror

2. Use "git-pull" to keep this repository (MirrorRep) in sync with the
main repository. I added entry in /etc/crontab to invoke "git-pull"
after every 10 minutes to update this repository.

3. Launch "git-daemon" so that local users can access and clone from
this  Mirror Repository.
         git-daemon --export-all --verbose --base-path=<base path to
MyMirror directory>

After this the users can easily clone from the local repository and
work with it. The problem is that the branches that were present in
MainRep are not visible in the clones made using MirrorRep. When
MirrorRep was created all the branches of MainRep became remote
branches for MirrorRep. And when users make a clone from MirrorRep
none of the remote branches are transfered over.

I came to know about --mirror option of git-clone and used it to make
a bare repository replica of the MainRep. Now i am not sure how to
keep it in sync with the MainRep.

Thanks
Yaser

```

## Santi Béjar, 2008-11-06 15:33

Subject: Re: Setting Up a GIT Repository Mirror
Message-ID: <adf1fd3d0811060733t28008f0cld1a3b3c5bf4ff4d8@mail.gmail.com>
URL: https://gitlist.dev/e/adf1fd3d0811060733t28008f0cld1a3b3c5bf4ff4d8%40mail.gmail.com
In-Reply-To: <e97d51700811060708y5deb9e9ek4a36c012726b3a63@mail.gmail.com>

```
On Thu, Nov 6, 2008 at 4:08 PM, Yaser Raja <yrraja@gmail.com> wrote:
> Hi
[...]

> I came to know about --mirror option of git-clone and used it to make
> a bare repository replica of the MainRep. Now i am not sure how to
> keep it in sync with the MainRep.

$ git fetch

as it is bare you cannot merge, so you cannot pull.

HTH,
Santi

```

## Yaser Raja, 2008-11-07 07:17

Subject: Re: Setting Up a GIT Repository Mirror
Message-ID: <e97d51700811062317s351e165eh14d4343223a8e91f@mail.gmail.com>
URL: https://gitlist.dev/e/e97d51700811062317s351e165eh14d4343223a8e91f%40mail.gmail.com
In-Reply-To: <adf1fd3d0811060733t28008f0cld1a3b3c5bf4ff4d8@mail.gmail.com>

```
On Thu, Nov 6, 2008 at 8:33 PM, Santi Béjar <santi@agolina.net> wrote:
> On Thu, Nov 6, 2008 at 4:08 PM, Yaser Raja <yrraja@gmail.com> wrote:
>> Hi
> [...]
>
>> I came to know about --mirror option of git-clone and used it to make
>> a bare repository replica of the MainRep. Now i am not sure how to
>> keep it in sync with the MainRep.
>
> $ git fetch
>
> as it is bare you cannot merge, so you cannot pull.
>
> HTH,
> Santi
>

Here is what i get when i try to use git-fetch:

# git fetch
ssh: : Name or service not known
fatal: The remote end hung up unexpectedly

Following is the current content of my config file:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[remote "origin"]
        url = ssh://gituser@<addr removed>
        fetch = +refs/*:refs/*
        mirror = yes

I also tried git-fetch with the url as argument but that also gave the
same error. Do i need to do some additional configurations to make
fetch work?

Thanks
Yaser

```
