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
- Login to code.harvard.edu
- Create new repository, for help use: https://help.github.com/articles/create-a-repo/.
...
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:
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/
Code Block language bash theme MidnightRDark 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 | ||||
---|---|---|---|---|
| ||||
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 |
---|
|
Remove your token
if you created a token above, then delete it
go to : https://code.harvard.edu/settings/tokens then delete it.
...