Skip to contentSkip to conversation

Pull From Mirrored Repository

DISCUSSION Jean Sacren 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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,

Signature · 1 line
Jean Sacren
#1 lore raw
Quoted 11 lines · Jean Sacren

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

#2 lore raw

From: Andrew Ardill <[email protected]>
Date: Mon, 19 Sep 2011 01:15:47 +1000

Quoted 6 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.

Quoted 3 lines

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.

Quoted 5 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.

Quoted 7 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!

Signature · 1 line
Jean Sacren