Connecting Cloud IDE to GitHub, Bitbucket or any other code repository

  • Last updated
  • 1 minute read

Goal

Connect Cloud IDE to a non-Acquia Git repository.

Prerequisites

  • Access to Cloud IDE

Overview

When you pull your application into Acquia Cloud IDE, we automatically copy your Acquia-hosted codebase, database and files from the Acquia Cloud Platform (via the Cloud Platform API) so that you can start developing Drupal right away.

And of course, you can easily connect your Cloud IDE to Acquia Code Studio with just a few extra commands.

But what if you have a different developer workflow? If you use GitHub, GitLab or Bitbucket, or even another third part source code management service, we’ve got you covered. Setup is straight forward. By simply using  Git and SSH, you can quickly set up a connection to any source code management service, and  Acquia CLI will make it easy.

  1. Pulling a non-Acquia hosted Git repository into Cloud IDE

    Connecting Cloud IDE to a non-Acquia hosted Git repository is easy. But before you can pull your code, Cloud IDE must be granted the permissions to connect to the remote server, so operations remain secure at all times.

    At a high level this is how it works:

    1. Generate an SSH key in Cloud IDE.
    2. Configure your code management tool by adding the public half of your new SSH key.
    3. Clone your non-Acquia hosted repository into Cloud IDE.

     

  2. Generate an SSH key in Cloud IDE

    If you’ve already set up your Cloud IDE by following the “Get Started” instructions, skip to the next step.

    If you're using a brand new Cloud IDE, first complete the "Get Started" instructions. Click on the CONFIGURE IDE button. This opens up a Terminal window and automatically creates and uploads an SSH key that is associated with your Acquia Cloud Platform account.

    Once this is done, you should have a new SSH key pair generated under /home/ide/.ssh - It takes the form:

    • Private key: id_rsa_acquia_ide_UUID
    • Public key: id_rsa_acquia_ide_UUID.pub

    As with any SSH key, you should never share the private key with anyone. The public key is meant to be installed on other servers so you can successfully establish a secure connection with your IDE.

  3. Configure your code management tool to add the new SSH key

    In this tutorial, we’ll be demonstrating how to add a key with GitHub, but almost identical steps should work with any other vendor.

    Print the contents of your Cloud IDE’s  public SSH key to the screen and copy it to your clipboard. Here’s an example:

    cat /home/ide/.ssh/id_rsa_acquia_ide_6a31f8b5-721a-4w18-969a-06247545befb.pub
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDfRLKksa4bt5csbnDbz7Xzl2Z0abYeLq6o2G5FXyihJLBCj/wB3aWT/wM5buSv+DPi6ZFfCm9LMlpd2VxSJcgiOs/6oUnsDKnw8552piRiYb1huzBSqU3j7mMtn3S+T0xQKVpzKAb0w2DHHYzuy4w/+/+02pslC+594YUjydEidJHAS3wORbkcGQr1rrpn2gj8nEQhUmnwiywnK1QBPd07tdXglJBXtvN+jq1gvdjsInPfU2DnzOnvZ8R6HC9Q9WGQfGLCDq+yS9+d5MRxbZ5VD27pd94RD/1LAjPk6+askMunL8UZTH9XOe9yfxPIpnLVUnOiMgmqnmaHPRjTQGj/AZCtJVNmAE0sDSxS5OHuLpte26nlnyTX+9WoRS8QxHkVy9ubAshsRQfMTh39cxVhUnlvTqvKXuh+iLQkJFn/iBA93gKX33Tr9eP5gxi89DFwfSZakJ6bamF6FGCjZ2Aj3p7wl74xHSCZv5x+XXKatwuLt2XdtqPrp7b+F1sbzL4kowL3xZwoAmhzLOOMYwOjyT/NmfkH9uYnqQj60WoTeZH5eGFpMuhj/irCBPluDxl0oeVcf7M0eL3zqLhhQkYw6j/LF7goNNIDN2oUgF4CbH0SIP11ay/GK/W6ZBqNapbMc5sUNz9p3cX09XTJCG1PYGtmDUS6UoAaBBs2ikYi5w== ide@ide-7caded55-724c-4fee-b330-e0scb6335bb9-84b6f9d7fd-vz9j7

    GitHub has an excellent documentation page to add a new SSH key to your GitHub account. In a nutshell, visit https://github.com/settings/ssh/new and paste your key there. Give it a meaningful name so you remember it weeks from now.

  4. Clone your non-Acquia hosted repository into Cloud IDE

    Your Cloud IDE is now able to establish an SSH connection to your GitHub repository. so you can easily clone your repository.

    Navigate to /home/ide/project and ensure the directory is empty. Then, clone your GitHub repository. Here’s an example:

    git clone [email protected]:margaret/margaret.git .
    Cloning into '.'...
    Warning: Permanently added the ECDSA host key for IP address '140.84.113.3' to the list of known hosts.
    remote: Enumerating objects: 40, done.
    remote: Counting objects: 100% (40/40), done.
    remote: Compressing objects: 100% (33/33), done.
    remote: Total 40 (delta 1), reused 0 (delta 0), pack-reused 0
    Receiving objects: 100% (40/40), 1.74 MiB | 16.49 MiB/s, done.
    Resolving deltas: 100% (1/1), done.
    

    Congratulations, you made it here!

  5. Pull your database and files into Cloud IDE

    Now that your codebase is available in Cloud IDE, one last step you might wonder about is how to only pull your database and files directory? There again we have your back!

    From your Cloud IDE’s “Get Started” page, you can click on the “database and files” link just below the COPY FROM THE CLOUD PLATFORM button. This instructs Acquia CLI to only pull your database and files while omitting the codebase, which is exactly what we need.

    As you can see, Acquia Cloud IDE is simple and flexible to adapt to your preferred developer workflow.

    Alternatively, you can also directly run Acquia CLI commands to pull down the Drupal files and database from your Cloud application:

    acli pull:db
    acli pull:files
    

    Create 1 for free today or request a demo!