a-repository is the repository we'd like to mirror and b-repository is the mirroring repository. b-repository will mirror the a-repository and take any future updates going into a-repository.
Follow the steps in the article Duplicating a repository but change the names as follows: old-repository corresponds to a-repository and new-repository corresponds to b-repository.
Check the current remote urls for b-repository:
cd b-repository
git remote show origin
and the output should start with:
* remote origin
Fetch URL: [email protected]:<username>/b-repository.git
Push URL: [email protected]:<username>/b-repository.git
The following connects the b-repository to fetch updates from a-repository as a:
cd b-repository
git remote add a [email protected]:<username>/a-repository.git
Doing the following:
git remote show -v
Should now starts with:
a [email protected]:<username>/a-repository.git (fetch)
a [email protected]:<username>/a-repository.git (push)
origin [email protected]:<username>/b-repository.git (fetch)
origin [email protected]:<username>/b-repository.git (push)
Now you may do the usual:
cd b-repository
git pull # pulls from [email protected]:<username>/b-repository.git
...
git push origin master # pushes changes to [email protected]:<username>/b-repository.git
Remember that we labelled the a-repository as a:
cd b-repository
git pull a master # can use any other branch than master