# Pushing to a remote repo from a remote repo?

5 messages from 2012-04-14 to 2012-04-16. Participants: Brian Cardarella, Carlos Martín Nieto, Jakub Narebski, Jeff King.
Thread: https://gitlist.dev/t/30246

## Brian Cardarella, 2012-04-14 22:08

Subject: Pushing to a remote repo from a remote repo?
Message-ID: <CAAnwhhWTcfOi+qqXPnGNXSKHbFh5L=+6eSKaaex5mq6VTwSxEw@mail.gmail.com>
URL: https://gitlist.dev/e/CAAnwhhWTcfOi%2BqqXPnGNXSKHbFh5L%3D%2B6eSKaaex5mq6VTwSxEw%40mail.gmail.com

```
So I have a destination repo that is remote. And I have a source repo
that is also remote. I would like my local machine to act as a proxy
to allow me to push to the destination from the source without ever
download the repo to my machine. Is this possible?

```

## Carlos Martín Nieto, 2012-04-14 23:02

Subject: Re: Pushing to a remote repo from a remote repo?
Message-ID: <1334444541.7825.1.camel@beez.lab.cmartin.tk>
URL: https://gitlist.dev/e/1334444541.7825.1.camel%40beez.lab.cmartin.tk
In-Reply-To: <CAAnwhhWTcfOi+qqXPnGNXSKHbFh5L=+6eSKaaex5mq6VTwSxEw@mail.gmail.com>

```
On Sat, 2012-04-14 at 18:08 -0400, Brian Cardarella wrote:
> So I have a destination repo that is remote. And I have a source repo
> that is also remote. I would like my local machine to act as a proxy
> to allow me to push to the destination from the source without ever
> download the repo to my machine. Is this possible?

Using your computer as a proxy and avoiding downloading the information
to your computer are mutually exclusive goals.

At any rate, git doesn't support this kind of operation. If you want to
move data from A to B, you need to push from A or fetch from B (or fetch
from A to C and then push from C to A).

   cmn


```

## Brian Cardarella, 2012-04-14 23:16

Subject: Re: Pushing to a remote repo from a remote repo?
Message-ID: <CAAnwhhXPs0+GPExMu8TP0jbctMamg6FZW2ndcQMJbtqGetfyZw@mail.gmail.com>
URL: https://gitlist.dev/e/CAAnwhhXPs0%2BGPExMu8TP0jbctMamg6FZW2ndcQMJbtqGetfyZw%40mail.gmail.com
In-Reply-To: <1334444541.7825.1.camel@beez.lab.cmartin.tk>

```
Yes, I assumed the bits need to come through my system. I want to
avoid cloning, pushing, then removing the repo. But it seems that is
not possible. Thank you.

- Brian

On Sat, Apr 14, 2012 at 7:02 PM, Carlos Martín Nieto <cmn@elego.de> wrote:
> On Sat, 2012-04-14 at 18:08 -0400, Brian Cardarella wrote:
>> So I have a destination repo that is remote. And I have a source repo
>> that is also remote. I would like my local machine to act as a proxy
>> to allow me to push to the destination from the source without ever
>> download the repo to my machine. Is this possible?
>
> Using your computer as a proxy and avoiding downloading the information
> to your computer are mutually exclusive goals.
>
> At any rate, git doesn't support this kind of operation. If you want to
> move data from A to B, you need to push from A or fetch from B (or fetch
> from A to C and then push from C to A).
>
>   cmn
>

```

## Jakub Narebski, 2012-04-15 10:09

Subject: Re: Pushing to a remote repo from a remote repo?
Message-ID: <m3lilx9uhf.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3lilx9uhf.fsf%40localhost.localdomain
In-Reply-To: <CAAnwhhWTcfOi+qqXPnGNXSKHbFh5L=+6eSKaaex5mq6VTwSxEw@mail.gmail.com>

```
Brian Cardarella <brian@dockyard.com> writes:

> So I have a destination repo that is remote. And I have a source repo
> that is also remote. I would like my local machine to act as a proxy
> to allow me to push to the destination from the source without ever
> download the repo to my machine. Is this possible?

First, you can set up either SSH tunnel (for SSH transport), or HTTP
proxy (`http_proxy`[1] environment variable or `http.proxy` config
variable[2] for HTTP transport, both smart and dumb), or git proxy
(`core.gitproxy`, e.g. netcat or ssh, for git:// protocol)

Second, you can configure repository using hooks so that pushing to
said intermediate repository would push to destination repository.  In
this solution you would have repository on disk on intermediate
machine, but you can avoid manual transfer to and from intermediate
machine.

[1] curl(1) manpage, the "Environment" section
[2] git-config(1) manpage

HTH
-- 
Jakub Narebski

```

## Jeff King, 2012-04-16 14:47

Subject: Re: Pushing to a remote repo from a remote repo?
Message-ID: <20120416144726.GA13688@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120416144726.GA13688%40sigill.intra.peff.net
In-Reply-To: <CAAnwhhXPs0+GPExMu8TP0jbctMamg6FZW2ndcQMJbtqGetfyZw@mail.gmail.com>

```
On Sat, Apr 14, 2012 at 07:16:36PM -0400, Brian Cardarella wrote:

> Yes, I assumed the bits need to come through my system. I want to
> avoid cloning, pushing, then removing the repo. But it seems that is
> not possible. Thank you.

This isn't really a git problem, but rather a network proxying problem.
You could solve it with netcat and ssh like:

  # forward port 5001 on our local box to ssh on the "source" box
  nc -lp 5001 -c 'nc $source 22' &

  # forward port 5001 on the destination box to our local forward,
  # and then start the clone
  ssh -R 5001:localhost:5001 $dest \
    'git clone ssh://localhost:5001/path/to/repo'

If the repository is accessible by http, then you can easily tweak it to
forward to port 80. If, for some reason, you prefer push rather than
fetch, you can create the tunnels in the reverse direction.

-Peff

```
