Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Error: Command failed: git push heroku HEAD:refs/heads/main --force

See original GitHub issue

Below is the error I received:

Screenshot 2021-02-19 at 2 05 17 PM

And this is my main.yml file:

name: Deploy

      - master

    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - name: Install packages
        run: npm install
      - name: Build project
        run: npm run-script build
      - uses: akhileshns/heroku-deploy@v3.11.10 # This is the action
          heroku_api_key: ${{secrets.HEROKU_API_KEY}}
          heroku_app_name: "git-auto" #Must be unique in Heroku
          heroku_email: ""
          procfile: "web: npm start"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

IshaanOhricommented, Feb 22, 2021

So I figured out the exact problem and the exact solution for this. If we connect the repository on Heroku for automatic deployments, then what happens is that as soon as a commit is pushed, the repository content on Heroku changes and the GitHub Action is also triggered, which makes use of the repository content on Heroku, makes some changes to it and pushes it back to Heroku. In between the GitHub action accessing the Heroku content and pushing it back to Heroku, the content on Heroku changes due to automatic deployment which causes differences in the content, because of which this error arises.

The solution to this is to not enable the automatic deployment on Heroku.

I really feel this is worth mentioning as an important note in the README, therefore I have made the required changes and have generated a PR for the same. Would appreciate merging the PR and closing the issue.

IshaanOhricommented, Feb 23, 2021

Thanks for providing the correct information. That was the probable explanation I could think of. My bad. But yeah, the problem was related to Automatic Deployments. Thanks, man!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Command failed: git push heroku HEAD:refs ... - GitHub
This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint:...
Read more >
Why can't I deploy to Heroku in GitHub Action: `Command ...
Specifically, the error was: Error: Command failed: git push heroku HEAD:refs/heads/main. and decide whether you wish to modify your GitHub ...
Read more >
Deploying with Git - Heroku Dev Center
To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your...
Read more >
Heroku Deployment Failed To Push Some Refs? - ADocLib
Failed to Push Some Refs | Git Error This means that someone else pushed a commit to the same branch you're pushing to...
Read more >
heroku: [solved] failed to push some refs - DEV Community ‍ ‍
In my case, I got the error because my github default branch isn't master but main . So in my situaton instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found