References:
ITER git repository: https://git.iter.org/projects/IMEX/repos/gittest/browse
ACH gitlab repository: https://gitlab.eufus.psnc.pl/ach/gittest
Step by step instructions:
- Create or select origin repository, in this case it was ITER git repository
Clone origin repository with --
mirror
flag:Code Block git clone --mirror ssh://git@git.iter.org/imex/gittest.git
Change directory to newly cloned mirror repository:
Code Block cd gittest.git
Push mirrored repository to new origin with
--mirror
flag:Code Block git push --mirror git@gitlab.eufus.psnc.pl:ach/gittest.git
Info title Warning! Don’t use
git push --mirror
in repositories that weren’t cloned by--mirror
as well. It’ll overwrite the remote repository with your local references (and your local branches).Clone newly pushed repository and change directory to it:
Code Block cd ..git clone git@gitlab.eufus.psnc.pl:ach/gittest.gitcd gittest
Check current remote repository:
Code Block git remote -v
It shall print:
Info icon false origin git@gitlab.eufus.psnc.pl:ach/gittest.git (fetch)
origin git@gitlab.eufus.psnc.pl:ach/gittest.git (push)Rename current default remote repository label to more relevant name:
Code Block git remote rename origin gitlab
And check the result:
Code Block git remote -v
It shall print:
Info icon false gitlab git@gitlab.eufus.psnc.pl:ach/gittest.git (fetch)
gitlab git@gitlab.eufus.psnc.pl:ach/gittest.git (push)Add second remote (ITER, original one):
Code Block git remote add iter ssh://git@git.iter.org/imex/gittest.git
And check results:
Code Block git remote -v
It shall print:
Info icon false gitlab git@gitlab.eufus.psnc.pl:ach/gittest.git (fetch)
gitlab git@gitlab.eufus.psnc.pl:ach/gittest.git (push)
iter ssh://git@git.iter.org/imex/gittest.git (fetch)
iter ssh://git@git.iter.org/imex/gittest.git (push)- To push or pull to different remote:
- PUSH:
Gitlab:
Code Block git push gitlab <optionally-branch-name}
ITER:
Code Block git push iter <optionally-branch-name>
Info title Note First push to newly added remote should be executed with {--set-upstream} flag, e.g.:
Code Block git push --set-upstream iter master
- PULL:
Gitlab:
Code Block git pull gitlab <optionally-branch-name>
ITER:
Code Block git pull iter <optionally-branch-name>
- PUSH: