If you have a LookML project that is connected to a Git repository, you might want to move that project's LookML to a new repository.
There are two possible approaches to this problem, both of which are described in the following sections:
- Reset the Git connection: This simple solution preserves all personal and shared branches in Looker and is suitable for the majority of use cases.
- Clone the Git repository: This advanced solution is preferred when it is important to be able to immediately see the complete history of all branches ever used through your Git provider's UI.
Simple solution: Resetting the Git connection
If you reset the Git connection and enter a new Git repository 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:
- Navigate to the Project Settings page for that project.
- On the Configuration tab of the Project Settings page, select 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), and then select Continue.
- If you are using SSH to connect, be sure to select Reset Key. 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.
Once you have followed these steps, your project will be 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 Git Actions panel).
Advanced solution: Cloning the repository
The simple solution described previously 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 to immediately view all branches and their history through 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 or project configuration page.
For this example, suppose that git@github.com:looker/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:looker/PROJECT_NAME.git cd PROJECT_NAME git checkout master git pull
-
Reset the repo's remote URL. See the GitHub documentation for more information.
git remote -v
This shows you the remote(s) to which your repo is currently pointing. The results will look something like this:
origin git@github.com:looker/PROJECT_NAME.git (fetch) origin git@github.com:looker/PROJECT_NAME.git (push)
-
Next, 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 shown in the following example:#!/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 earlier on this page).