Motivation:

In general it makes sense to have a dbt project inside a version controlled directory. In this short tutorial I will show a way to create a dbt project, push it to github and use it inside dbt cloud.

Step-by-step guide:

Following just the steps to start a new version-controlled dbt project, load it to github and use it inside dbt cloud.

  1. Login to your virtual environment where dbt is installed and activate it. More here

    source bin/activate
    
  2. Go to the directory where you want to save your dbt project.

  3. Start a new dbt project with a PROJECT_NAME.

    dbt init PROJECT_NAME
    
  4. Quickly check the structure of the project. It should match the structure described in this post

  5. The dbt project should be versioned controlled. Check - In the project to git. First go the project folder.

    cd PROJECT_NAME
    git init
    
  6. Add the files of the project.

    git add .
    
  7. Make the first commit to your local repository.

    git commit -m "initial commit"
    
  8. Create a repository in your Github account.

  9. Copy the URL of the repository.

  10. Add the URL of the remote repository

    git remote add origin URL 
    
  11. Push the local repository to the remote Github repository

    git push -u origin master
    
  12. Now go to getdbt and sign-up for dbt cloud.

  13. I will just show how to setup the repository and use it inside the Cloud IDE but not how to setup the whole dbt cloud. Have a look to the documentation if you need to.

  14. Go to the settings and choose Github repository.

  15. Copy the deploy key and enter the deploy key on Github to your project under settings and deploy key.

  16. Now go to the Cloud IDE and the project should appear. Now you can code in the Cloud IDE or just schedule runs on top of the Github repository and have it versioned controlled on Github.