Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

  1. Create or select origin repository, in this case it was ITER git repository
  2. Clone origin repository with --mirror flag:

    Code Block
    git clone --mirror ssh://git@git.iter.org/imex/gittest.git


  3. Change directory to newly cloned mirror repository:

    Code Block
    cd gittest.git


  4. Push mirrored repository to new origin with --mirror  flag:

    Code Block
    git push --mirror git@gitlab.eufus.psnc.pl:ach/gittest.git


    Info
    titleWarning!

    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).


  5. Clone newly pushed repository and change directory to it:

    Code Block
    cd ..git clone git@gitlab.eufus.psnc.pl:ach/gittest.gitcd gittest


  6. Check current remote repository:

    Code Block
    git remote -v

    It shall print:

    Info
    iconfalse

    origin    git@gitlab.eufus.psnc.pl:ach/gittest.git (fetch)
    origin    git@gitlab.eufus.psnc.pl:ach/gittest.git (push)


  7. 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
    iconfalse

    gitlab    git@gitlab.eufus.psnc.pl:ach/gittest.git (fetch)
    gitlab    git@gitlab.eufus.psnc.pl:ach/gittest.git (push)


  8. 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:


    `git clone
    Info
    iconfalse

    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`

    git (push)


  9. To push or pull to different remote:
    1. PUSH:
      1. Gitlab:

        Code Block
        git push gitlab <optionally-branch-name}


      2. ITER:

        Code Block
        git push iter <optionally-branch-name>


        Info
        titleNote

        First push to newly added remote should be executed with {--set-upstream} flag, e.g.:

        Code Block
        git push --set-upstream iter master



    2. PULL:
      1. Gitlab:

        Code Block
        git pull gitlab <optionally-branch-name>


      2. ITER:

        Code Block
        git pull iter <optionally-branch-name>