To migrate a repository from a git based version control (like github, Bitbucket , code.seas.harvard.edu , etc ) to Harvard Enterprise GitHub
- Create a repository in code.harvard.edu
- Use git commands to move the repository contents.
Example: Suppose we want to migrate aws_devops (git@bitbucket.org:harvardseas_sysops/aws_devops.git) from Bitbucket to Harvard Enterprise GitHub.
Create new repository "aws_devops" in code.harvard.edu using the UI or API
Using the website
- Login to code.harvard.edu
- Create new repository, for help use: https://help.github.com/articles/create-a-repo/.
Or with API calls
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:
on https://code.harvard.edu/settings/tokens -> Generate new token (or https://code.harvard.edu/settings/tokens/new).
fill out the Token description
check the "Repo" box in the Select Scope.
For more help with the personal token look at: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line
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/
AUTH_TOKEN=f1af1e2a1985d6f789f85505b28de329185e4cf4 DATA='{"name":"aws_devops", "description":"aws_devops 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/aws_devops.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.
git clone --mirror git@bitbucket.org:harvardseas_sysops/aws_devops.git cd aws_devops git remote remove origin git remote add origin git@code.harvard.edu:SEAS/aws_devops.git git push origin --mirror
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.