Troubleshooting Heroku deploys with empty Git commits

When troubleshooting Heroku deployments, you need to push to the Heroku remote over and over until you've found the problem. It's necessary to add new Git commits in order to force Heroku to re-compile your application slug or else you will get the Everything up-to-date message back from Git.

Rather than making trivial changes all the time, you can add empty commits.

git commit --allow-empty -m "Force slug recompilation"

It still adds unnecessary commits to your repo, but it's cleaner and at least you're not touching any code.


Simon Starr has mentioned another method to achieve the same thing. Using Git with the --amend flag.

git commit --amend

Usually, this is used to add missing files to your previous commit or change the commit message, but it also removes the previous commit and creates a new one, which means that Heroku will update and re-compile without a problem.

Be careful though, this is not a good method if you've already shared your commits with someone else, but it's worth bearing in mind depending on the situation as it saves you adding any new commits to your repo. Thanks, Simon.