1

I have a repo(we calls it as repo X) that maintaining by another group. For some reason I have only read access(can't add new branch) for this repo.
So I've to mirror it and migrate a same one(call repo Y) on our own server. And every day we want synchronization this repo.

But we're face a problem.

The original repo have 3 branches:
branch A, branch B, branch C

And the repo on our server have 2 more branches:
branch E, branch F

Because we want to synchronization code from repo X, so we mirror it and push it to our server.
But we found that our own branch E, F is deleted.

Is there any good way to solve this problem?

Generally speaking, what we need is to have a new repo Y on our own server, and we could make our own changes on it, but still we could fetch the newest changes form the original repo X.

Mouloud85
  • 3,826
  • 5
  • 22
  • 42
Richardicy
  • 103
  • 1
  • 1
  • 4
  • `git fetch upstream` seems like what you're looking for with remote set to the original repo. – Naman Sep 15 '17 at 03:53

1 Answers1

0

If you cannot directly "fetch upstream" from the target repo, meaning you have to use an intermediate repo, then don't use push --mirror: deleted refs will be removed from the remote end.

Try git push --all instead, after making sure your intermediate repo is tracking all the branches of the original repo: see this command.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi, I try did so, but after I use git push --all, I found there're only a master branch is created. – Richardicy Sep 18 '17 at 05:36
  • That is because you didn't create local branches first. See the last link in my answer. – VonC Sep 18 '17 at 05:39
  • Hi, I tried and result is ok. But seems there is a problem, that is the remote repo delete Branch A, local repo will not also delete the Branch A if you use git push --all – Richardicy Sep 19 '17 at 00:27