Setting Up Version Control

On this Page
Docs Menu

Git Integration

Looker generally uses GitHub for LookML source file management. However Looker also can be configured to work with other Git providers such as GitLab, Bitbucket, or any Git server that can use an SSH key for authentication.

Looker uses Git to record changes and manage file versions. Each LookML project corresponds with a Git repository, and each user’s development mode correlates to a Git branch. Git repositories are often called “repos”.

To access Git integration options, you must have Development Mode turned on.

Connecting Looker to a Git Repository

Looker can use several different version control providers for LookML file management, but the general steps are the same no matter which platform you use.

If your Github repo is hosted by Looker, talk to your Looker analyst or the chat team for help with setting up Git.

This example shows the steps for connecting Looker to GitHub once you have created a GitHub repository.

  1. From your project in Looker:

    • For a new project, click the Configure Git button.
    • If you want to change the Git setup for an existing project, click on the Git menu and select Project Settings, then click the Reset Git Connection button from the Project Settings page.

    Resetting your Git connection will erase your Git history. In order to preserve the Git history for existing Git connections, see this article.

  1. Get the SSH URL for your Git repo. Here are the formats for common Git providers:

    • GitHub: git@github.com:<organization-name>/<repository-name>.git
    • GitHub Enterprise: git@example.com:<organization-name>/<repository-name>.git
    • GitLab: git@gitlab.com:<organization-name>/<repository-name>.git
    • Bitbucket: git@bitbucket.org:<organization-name>/<repository-name>.git
    • Phabricator: ssh://username@example.com/diffusion/MYCALLSIGN/<repository-name>.git

    In the case of GitHub, for new repositories (repositories that don’t yet contain any files), GitHub will show you the SSH URL as part of the initial setup. Be sure to click the SSH button so you get the SSH URL, then click the copy button to copy it to your clipboard:

    For existing GitHub repositories (repositories that already contain files), you can see the SSH URL by going to the repository’s Code tab and clicking on the Clone or download button. You can click the button to copy to your clipboard:

  2. In Looker’s Configure Git screen, paste the SSH URL for your Git repository, then click Continue.

    URLs with custom or non-standard git ports can be used with Looker by adding the non-standard port number to the git URL. For example: ssh://git@corporate.git.server.com:22/myorganization/myproject.git
    Please note that you must include the ssh:// for this to work properly.

  3. Looker will detect your Git provider and display a deploy key for your repo. (If Looker does not successfully detect your Git provider, it will ask you to choose from a dropdown.) Select the entire Deploy Key and copy it to your clipboard, then click on the Deploy Key settings for your repository link to open the Deploy keys page for your GitHub repository.

  4. In the GitHub Deploy Keys page, click on the Add deploy key button:

  5. Add a title for the deploy key. The name isn’t important, but you might want to include “Looker” and your project title to keep track of it in the future.

  6. Paste the deploy key that you copied from Looker.
  7. Select the Allow write access option.
    This is an important step, because Looker requires this setting in order to make and deploy changes to your LookML model.
  8. Click the Add key button. (At this point, GitHub may prompt you to enter your password. If so, enter your GitHub password then click Confirm password.)
  9. GitHub will show all of the deploy keys that have been added for your repository.
  10. Go back to your Looker window and click Continue Setup in the Configure Git screen.

Git is now configured for your LookML project. From here you can validate your LookML, and then create your initial commit and deploy to production to make your project available in production mode. You can also:

Git Connection Test Tool

Looker provides a Git Connection Test to verify your Git connection. The Git Connection Test verifies that you’ve set up the correct Git URL and that the Git host is reachable by Looker. The Git Connection Test also verifies that you have provided a valid Git deploy key and that the deploy key has write access to your Git repository.

If Looker is unable to connect to your Git repository, you will see the Test Git Connection button:

You can also access the Git Connection Test tool at any time by holding Shift while clicking the Git menu:

The Git Connection Test tool then displays the steps it is taking to test the Git connection. Here is an example of a successful test:

In this example, the Git repository does not have a deploy key configured for the Looker connection:

Project Settings

The Project Settings page has additional configuration options for your project. To see this page, open your project and select Project Settings from the Git menu:

On the Projects Settings page, you can configure:

  • Name — The name of your project. You can rename your project by editing the text and clicking the Update Project Settings button. See this page for more details.
  • Code Quality — The option to require developers to successfully run the LookML Validator on the project before committing any changes to the project. You can turn this on or off by clicking the check box and then clicking the Update Project Settings button.
  • Git Integration — The levels of integration with your Git provider. See Git Integration Options for details.
  • Reset Git Connection — This button opens the Configure Git window, where you can update the connection settings for your Git repository.

Resetting your Git connection will erase your Git history. In order to preserve Git history, see this article.

In addition, at the bottom of the Projects Settings page you can see your project’s current Git settings:

Git Integration Options

Once you set up your Git connection, Looker will use your Git provider for managing your LookML source files, as described on this page. That’s all you need to do to set up your project with source file management and version control. However, you can configure additional options for Looker’s integration with Git using the Git Integration options on the Project Settings page.

In this example, we’re using GitHub, so the window shows GitHub Integration. However, if you are using a different Git provider, Looker will display your Git provider’s name instead.

Here’s what these Git integration options do:

  • Off — Looker will fully use your Git provider for managing LookML files, but Looker won’t display any external links to your Git provider’s interface.
  • Show Links — Looker will provide external links to your Git provider’s interface so that your developers can view the project in the Git provider’s interface. Also, Looker will provide links for each project file so that your developers can view the file’s history and Git blame information on your Git provider’s interface. See this section for information about the links.
  • Pull Requests Recommended — In addition to providing external links to your Git provider’s interface, Looker will allow developers to submit a pull request so that another developer can approve changes before adding them to the project. See this section for information on setting this up.
  • Pull Requests Required — This is the same as above, except that your LookML developers are required to open a pull request to submit changes to the project. See this section for information on setting this up.

The Pull Requests Recommended and Pull Requests Required options are only shown if you are self-hosting your repository using a Git provider as described in this section.

Integrating External Links to Your Git Provider

If you have enabled any of the extra Git integration options (Show Links, Pull Requests Recommended, or Pull Requests Required), Looker provides external links to your Git provider’s interface. These external links open a new browser tab to your Git provider’s site.

To view these external links, your developers must have an account with your Git provider, and must have access to the project’s Git repository.

In the gear menu for each of your LookML files, Looker provides links to your Git provider’s site to view the file, view the Git blame information for the file, and to view the commit history for the file:

In the Git menu, Looker provides a link to your project files on your Git provider’s site:

Integrating Pull Requests for Your Project

By default, Looker developers can commit and deploy their changes to production. However, instead of letting developers deploy their own changes to production, you can also set up your project with either the Pull Requests Recommended or the Pull Requests Required option.

The Pull Requests Recommended and Pull Requests Required options are only available if you are self-hosting your repository using a Git provider; these options won’t be shown if you are using a Looker-hosted repository for your LookML files. See this article for information about moving from a Looker-hosted repository to a self-hosted repository.

With either Pull Requests Recommended or Pull Requests Required, developers submit a Git pull request for the changes on their branch. The pull request can then be reviewed and approved by other developers before being deployed to production through your Git provider’s interface.

Looker supports pull request integration for the following Git providers: GitHub, GitLab, Bitbucket, and Bitbucket Server (which was previously called “Stash”).

To set up your Looker project with Git pull requests:

  1. From your project, select Project Settings from the Git drop-down menu.
  2. In the Git Integration section, select Pull Requests Recommended or Pull Requests Required.
  3. Copy the webhook information to your clipboard to use later in this procedure.
  4. Click Update Project Settings.

Next, use your Git provider’s interface to create a trigger for the webhook:

  1. Navigate to your project’s repository settings on your Git provider’s website.

TIP: Now that you’ve set up your project for Git integration, you can use the View Project on GitHub option from your project’s Git menu.

  1. In your repository’s settings, click on Webhooks.
  2. Click Add Webhook. This will open the Add Webhooks window.
  3. In the Payload URL text box, paste the webhook information you copied from the Git Integrations options in Looker.
  4. Select the option for Just the push event.
  5. Click Add Webhook.

And you’re set! Now, whenever a Looker developer commits changes to your project, the Looker IDE will show the Open Pull Request button. The button opens a new browser tab directly to the new pull request page on your Git provider’s website, and automatically fills in the title with the developer’s commit message from Looker:

Once the developer creates the pull request, the lead developer can approve it from the Git provider’s web interface, where the webhook will push changes to your Looker project’s production branch.

Some additional notes on using pull requests with Looker:

  • If a developer has issued a pull request that you would like to revert, see this article for information on reverting a pull request.

  • Git pull requests can also be used to enable a staging instance for Looker, so you can have a staging instance and a production instance, with pull requests enabled on the staging instance. All development and code review can be done in the staging environment and the reviewed code can then be deployed to the production instance as desired. To set this up, see this article.

Still have questions?
Go to Discourse - or - Email Support
Top