Pages

2015-02-02

[Ubuntu12.04]Mirroring Code from a Repository to Another on GitHub


For example, 

Original repository:
1. chilung/OCP_CI_Server_Certification_Test_Cases
2. HTTPS clone URL:
    https://github.com/chilung/OCP_CI_Server_Certification_Test_Cases.git

New repository:
1. opencomputeproject/ocp_ci_server_certification_test_cases
2. HTTPS clone URL:
    https://github.com/opencomputeproject/ocp_ci_server_certification_test_cases.git

And I want to duplicate code from original repository to new repository...

Requirements:
1. have access privilege to both project first(maybe collaborators)
2. create the new repository if there's no repository there. please refer to https://help.github.com/articles/create-a-repo/ 

Steps:
1. clone original repository to /opt
    $ git clone --bare https://github.com/chilung/OCP_CI_Server_Certification_Test_Cases.git
2. move to the directory, there is original repository info under this directory
    $ cd OCP_CI_Server_Certification_Test_Cases.git
3. push the code th new repository
    $ git push --mirror
    https://github.com/opencomputeproject/ocp_ci_server_certification_test_cases.git
4. exit original repository
    $ cd ..
5. remove temporary local repository
    $ rm -rf OCP_CI_Server_Certification_Test_Cases.git

Finally,
Original repository is still there:
https://github.com/chilung/OCP_CI_Server_Certification_Test_Cases

New repository generated:
https://github.com/opencomputeproject/ocp_ci_server_certification_test_cases


Referances:
https://github.com/chilung/OCP_CI_Server_Certification_Test_Cases
https://github.com/opencomputeproject/ocp_ci_server_certification_test_cases
https://help.github.com/articles/duplicating-a-repository/
https://help.github.com/articles/create-a-repo/

No comments:

Post a Comment