The Problem
I have a LookML project connected to a Git repository. I would now like to move that LookML to a new repository.
The Solutions
There are two solutions to address this problem, both of which are described in the following sections. The simple solution preserves all personal and shared branches in Looker and is suitable for the majority of use cases. The advanced solution is preferred when it is important to be able to immediately see the complete history of all branches ever used via your Git provider's UI.
Simple Solution: Reset the Git Connection
If you reset the Git connection and enter a new Git URL, then the LookML will be moved over to that repository. All saved changes in personal and shared branches will be maintained and usable in Looker. At first, your Git provider's UI will only show the master branch and its history. Other branches and their history will appear the next time a commit is made to that branch in Looker. To migrate to a new repository using this method, follow these steps:
- Enter Development Mode.
- Navigate to your project and click the Settings button in the left menu.
- Under the Configuration section, click Reset Git Connection.
- On the Configure Git page, enter the new Git URL (the Git URL for the repository to which you want to migrate), then click the Continue button.
- If you are using SSH to connect, click the Reset Key button when shown your deploy key. This prevents a conflict if both repositories are hosted by the same Git provider (for example, Github).
- For SSH connections, add the new deploy key to your Git repo, and be sure to grant Write access in the Git repo deploy key settings. If you are using HTTPS, enter the login credentials for your Git repo. See the Setting Up and Testing a Git Connection documentation page for full instructions on setting up Git
- Deploy your project to production.
Now your project is connected to the new repository.
Advanced Solution: Clone the repository
The simple solution above will preserve the history of all branches, but only the master branch and its history will be visible in the GitHub UI at first. Once a commit is made on a personal or shared branch in Looker, that branch and its history will appear in the GitHub UI. A more advanced solution is necessary in order to immediately view all branches and their history via the GitHub UI.
First, you need to have access to the original repository in GitHub (or other Git provider). You can find the repository URL at the bottom of the Project Settings/Project Configuration page. If it contains llooker/
, then the repository is Looker-hosted. We can grant access to a Looker-hosted repository for a limited time while you complete the migration; to get the process started, please contact us and include the repo URL and your Github user name. Once you have access, you can proceed with the following steps.
For this example, in a situation where git@github.com:llooker/PROJECT_NAME.git
is the original repo and git@github.com:your_organization/PROJECT_NAME.git
is the new repo:
-
Clone the original repository onto your computer, and pull down the branches you want to preserve.
git clone git@github.com:llooker/PROJECT_NAME.git cd PROJECT_NAME git checkout master git pull
- Reset the repo's remote URL (read more about this here).
git remote -v
This shows you the remote(s) to which your repo is currently pointing. The results will look something like:origin git@github.com:llooker/PROJECT_NAME.git (fetch) origin git@github.com:llooker/PROJECT_NAME.git (push)
- Now set the origin remote to the new repo:
git remote set-url origin git@github.com:your_organization/PROJECT_NAME.git git push origin master
- Now, to bring in history and files for dev branches, you'll need to do
git checkout dev_branch_name
andgit push origin
for each dev branch. This can be done manually, or in a loop in a script such as:#!/bin/bash for branch in $(git branch --all | grep '^\s*remotes' | egrep --invert-match '(:?HEAD|master)$'); do git branch --track "${branch##*/}" "$branch" done
Then push the branches with
git push --all
. -
Reset the Git connection in Looker to this new URL and set up a deploy key on this new repo (see the steps in the simple solution section above).