How to Move to a Different Git Repository Provider
Moving a Git Repository
Git makes it easy to clone repositories and to switch between Git providers such as GitHub, GitLab, Bitbucket, Azure DevOps, or AWS CodeCommit. Because Copado connects directly to the Git repository, you also need to update Copado if you migrate a repository. Since the development team and release process depend on the repository, this change needs to be done carefully but quickly.
These are the factors to consider:
- User access to the new repository.
- Migrate and test the new repository.
- Update Copado to connect to the new repository.
- Bonus: Create a backup repository if it is not yet available.
Once you start to create a repository, you need to be ready to switch it in Copado too, so perform connection testing before starting the switch with an empty repository.
A good time is probably Thursday afternoon/evening or Friday if there are no important deployments happening on Friday. This way you can change the setup if something goes wrong.
You can always roll back by simply providing the old clone url/username/password/base urls, so take a note of the values on the old Git repository record.
While you should take time to test beforehand, the final migration can be done in roughly 30 min.
Perform a test-commit and validation after the switch is done.
After gaining access to your new provider, ensure:
- Grant access to your users.
- If you have a group or team functionality, add them to the group/team so that you have an easy way to provide access to repositories.
- Ensure your users are able to work/commit on feature and promotion branches (at least).
- Create a system user, which will be used as the primary connection for Copado.
- Once the repository is created, grant the group/team collaboration (or edit) access to the new repository.
Create a New Repository with the Old Contents
In order to maintain work in progress we need to ensure commit Ids and branch names stay the same as before. The easiest way to do this is to import your old repository.
Here you will find instructions on how to import your old repository into some widely-known repository providers.
If you want to import your repository into Bitbucket follow these steps:
- Go to Bitbucket's home page.
- Click on the + sign on the left of the screen.
- Select Repository under Import.
- Provide your clone url for the old repository:
If you want to import your repository into GitHub follow the steps below:
- Log in to your GitHub account.
- Navigate to the Repositories tab and click on New on the left of the screen.
- In the new dialogue, click on the Import a repository hyperlink on top.
- Provide the clone URL of the old repository, set the owner and the privacy settings and click on Begin Import:
If you want to manually export/import your repository, follow these steps:
- Create a new empty repository in your new repository provider. Make a note of the clone url.
- Open your command line and run the following commands:
- Clone your old repository fully:
git clone --mirror <cloneURLofOldRepo> <nameOfTemporaryFolde
- Go to the directory of the cloned repository:
- Perform a push of the folder contents to the new repository target:
git push --mirror https://github.com/delokoni/newOldRepo.git
- Clone your old repository fully:
Verify the results after the command is finished in your target repository.
Connection with Copado
Your goal here is to know that connection is not an issue, so it needs to be tested before. Also, you want to change as little as possible in your current setup.
- Create a new repository in your Git repository provider. Make sure to copy the clone url. This repository will be dropped after the test, so there is no need to set up gitignore or branches.
- Create a new Git Repository record in Copado (name it, for instance, New Repo Test).
- Use the clone url and provide the username/password.
- Don’t care about the rest, you will not work with this repository record.
- If you see a green bar after the record is created, all good.
- If not, resolve connection issues. (IPs whitelisted? Correct Username/Password? Can you clone it outside of your network?...)
- Delete the testing repository in Git and the Git Repository record in Copado.
Connecting to Copado
- Go to the Git Repository record in Copado, which is currently used for your main pipeline.
- Modify the URI, username/password and the base URLs to fit your new main repository (the one you created for testing before).
- You can leave the rest as it is.
Bonus: Create a Backup Repository
If you don’t have a backup repository, now is the time to create one.
- Create a new repository in Git with a name that identifies it as a backup repository.
- Initialize the repository with an empty .gitignore file.
- Create branches for the main organizations in your pipeline. It is ok if they are empty.
- Create a Git Repository record in Copado linked to the new Git repository.
- Create a set of Git Snapshot records linked to the backup repository:
- Name the snapshots so that it’s visible they are for backup (e.g. DEV_BACKUP).
- Set the frequency to Daily.
- Git Repository: Select the backup repository you have created.
- Branch: The name of the branch as defined in the repository.
- Git Snapshot Permissions: Allow Snapshots Only.
- Execute the snapshot once you create them.
These snapshots will include all the metadata in an organization and will run automatically in the future on a daily basis.