Versions Compared

Key

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

 

To migrate a repository from a git based version control (like github, Bitbucket , code.seas.harvard.edu , etc ) to Harvard Enterprise GitHub

...

Example: Suppose we want to migrate aws_devops migrate my_test_repo (git@bitbucket.org:harvardseasmy_sysopsproject/awsmy_test_devopsrepo.git) from Bitbucket to Harvard Enterprise GitHub. 

Create new repository "

...

my_test_

...

repo" in code.harvard.edu using the UI or API

   Using the website

...

Note

Note that token and API calls are useful if you want to automate things or move multiple repositories at once.

    • Create a personal token in code.harvard.edu:

    • For Simplicity, assign the token value to a variable (say AUTH_TOKEN). 

    • Create a repository (private or public) in your organization (Like SEAS). Note that the list of available parameters to create a repository can be found here: https://developer.github.com/v3/repos/

      Code Block
      languagebash
      themeMidnightRDark
      AUTH_TOKEN=f1af1e2a1985d6f789f85505b28de329185e4cf4
      DATA='{"name":"awsmy_test_devopsrepo", "description":"awsmy_test_devopsrepo repo in Harvard GitHub" , "private": true, "has_wiki": true}'
      curl -H "Content-Type: application/json" -H "Authorization: token $AUTH_TOKEN" -X POST -d "$DATA" https://code.harvard.edu/api/v3/orgs/SEAS/repos
    • Write down the repository ssh URL . In this case it is "ssh_url": "git@code.harvard.edu:SEAS/awsmy_test_devopsrepo.git",

Migrate the repository

  • Clone the old repository 

  • Remove the old repository remote URL

  • Add the new remote repository URL, 

  • push to the remote repository.

Code Block
languagebash
themeRDark
git clone --mirror git@bitbucket.org:harvardseasmy_sysopsproject/awsmy_test_devopsrepo.git
cd awsmy_test_devopsrepo
git remote remove origin
git remote add origin git@code.harvard.edu:SEAS/awsmy_test_devopsrepo.git
git push origin --mirror
Note
  • The "–mirror" option is to map all the branches and tags.

  • You need to setup SSH keys to the push to a repository in code.harvard.edu

Remove your token

if you created a token above, then delete it

go to : https://code.harvard.edu/settings/tokens then delete it.

...