Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Trigger a Build on Heroku Using Git

Here are the command-line snippets used in this lesson:

$ cat .git/config
$ heroku git:remote --app <app-name> [--remote <remote-name>]
$ git push heroku
$ git push --set-upstream heroku master

00:00 In this lesson, you’ll learn about the integration of Heroku and Git, which is arguably the quickest and the most convenient way of pushing your code to the cloud.

00:09 Since most programmers are familiar with Git, Heroku leverages that knowledge and builds on top of it instead of introducing additional entry barriers. You might recall that creating a new Heroku app assigns a unique address in the Heroku domain, where your app will be hosted. However, there’s a second URL, which looks very much like a Git repository address.

00:29 And indeed, it’s a remote Git repository that Heroku prepares just for your app. When you type that command in a directory which also happens to be the home of your local Git repository, then something interesting happens. Heroku CLI will add that remote URL to your local repository’s configuration file. By default, it will define a Git remote called Heroku.

00:54 But if you’d like to hook up another Heroku app or one that you had created before, then you can do so by typing heroku git remote, then provide the app name

01:06 and an optional remote name.

01:13 Now you have two Git remotes that you can push code to as if they were GitHub and Bitbucket, for example.

01:20 But unlike those tools, Heroku isn’t meant for code collaboration. Instead, typing git push heroku will send your committed code to the remote server and trigger a build on the cloud infrastructure. The first time you do that, Git will ask you to associate your local branch with a remote one with the same name through the --set-upstream option.

01:43 Heroku knows how to build your project because it looks for specific files that are common in certain languages and frameworks. In this case, it correctly recognized a Python project. It picked up the requirements file and used Django’s management scripts to collect static resources.

02:02 Unfortunately, the build is failing at the moment because Django and your Heroku app need additional configuration. You’ll address that in the upcoming lesson.

Become a Member to join the conversation.