I found the answer on this blog comment https://coderwall.com/p/ssxp5q
If you come across the “Updates were rejected because the tip of your current branch is
behind. Merge the remote changes (e.g. ‘git pull’)” problem when you’re pushing (due to
whatever reason, esp screwing about with git history) then you’ll need to nest git
commands so that you can force a push to heroku. e.g, given the above example:
git push heroku `git subtree split --prefix pythonapp master`:master --force