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 we 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. To migrate to a new repository using this method, follow these steps:
Starting in Looker 7.12, the following actions are available on the Configuration tab of the Project Settings page in the new IDE. Navigate to the Project Settings page by clicking the Settings icon from the navigation bar.
- Go to the Project Settings page for that project:
- On the Project Settings page, click the Reset Git Connection button:
- 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, be sure to click the Reset Key button. Otherwise, the same SSH key will be used, which can cause a conflict if both repositories are hosted by the same service (in this case, 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).
That is all! Now your project is connected to the new repository.
Note: Your project LookML will not appear in the master branch of the new repository until you deploy your project to production. Unless you deploy to production, your LookML code will appear only on your development branch in the new repository after you commit the code, or push it to remote (a Git command available in the shift-click Git menu).
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).