threads / discuss / 28419

Pull From Mirrored Repository

Subject: Pull From Mirrored Repository

## tl;dr

3 messages between Sep 18, 2011 and Sep 18, 2011.

replies: 2people: 2as markdown or json

Jean Sacren· Sep 18, 2011, 14:45 UTC · lore
After pull from a mirrored repository, git status shows

# On branch master # Your branch is ahead of 'origin/master' by [NUMBER] commits. # nothing to commit (working directory clean)

How to bring 'origin/master' update without syncing with the original repository?

Thanks,
-- 
Jean Sacren
Andrew Ardill· Sep 18, 2011, 15:15 UTC · re: Jean Sacren · lore

Re: Pull From Mirrored Repository

On 19 September 2011 00:45, Jean Sacren <sakiwit@gmail.com> wrote:
Show 11 quoted lines
> After pull from a mirrored repository, git status shows
>
> # On branch master
> # Your branch is ahead of 'origin/master' by [NUMBER] commits.
> #
> nothing to commit (working directory clean)
>
>
> How to bring 'origin/master' update without syncing with the original
> repository?
>
Am I correct in thinking that you have done the following:

$ git clone original-server/repo.git $ cd repo $ git pull mirror-server/repo.git $ git status # On branch master # Your branch is ahead of 'origin/master' by [NUMBER] commits. # nothing to commit (working directory clean)

and now you want the remote ref 'origin/master' to point to the same thing as 'mirror/master' (assuming that you create the ref for the mirror)?

This can be done (by editing the file .git/refs/remotes/origin/master and specifying the correct sha1) however this is probably not the best idea. It is best for git to know the actual state of the remote the last time you synced with it so that it can act intelligently the next time you sync with it.

If you intend to sync with the mirror, you might as well set it as the upstream ref of you master branch. That way you will not get the 'Your branch is ahead' message when you pull new updates (unless you have local changes, of course). This can be done by: $ git checkout master $ git branch --set-upstream mirror

This assumes that you have already added mirror as a remote ref.

Regards, Andrew

Jean Sacren· Sep 18, 2011, 20:06 UTC · re: Andrew Ardill · lore

Re: Pull From Mirrored Repository

From: Andrew Ardill <andrew.ardill@gmail.com>
Date: Mon, 19 Sep 2011 01:15:47 +1000
Show 6 quoted lines
>
> Am I correct in thinking that you have done the following:
> 
> $ git clone original-server/repo.git
> $ cd repo
> $ git pull mirror-server/repo.git
Essentially that's what I did.
> and now you want the remote ref 'origin/master' to point to the same
> thing as 'mirror/master' (assuming that you create the ref for the
> mirror)?

The idea is to update the local tree from multiple sites so long as one of them is still running. And the update shall make no difference whether it is from the master site or not.

Show 5 quoted lines
> This can be done (by editing the file .git/refs/remotes/origin/master
> and specifying the correct sha1) however this is probably not the best
> idea. It is best for git to know the actual state of the remote the
> last time you synced with it so that it can act intelligently the next
> time you sync with it.

It turns out to be more of a bug with git. After a successful pull from a master or mirror site, the SHA1 shall be updated among all the master files in .git/refs/remotes/origin or .git/refs/remotes/[WHATEVER_MIRROR] as the tip of the local tree is updated.

Show 7 quoted lines
> If you intend to sync with the mirror, you might as well set it as the
> upstream ref of you master branch. That way you will not get the 'Your
> branch is ahead' message when you pull new updates (unless you have
> local changes, of course).
> This can be done by:
> $ git checkout master
> $ git branch --set-upstream mirror

This is a nice hack, but we want all the changes stay with the master branch. It's easier to use one master branch for tracking all updates from the upstream.

Thank you for all your help!
-- 
Jean Sacren

← back to recent threads