question-mark
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.

Deployment failed due to: 'Push rejected, cannot delete master branch'

See original GitHub issue

To preface im very new to heroku, it is my first time using it for a project.

I’m trying to publish a node app to heroku, the usefull parts of my main.yml can be found below;

When built my app ends up in a folder in the root called ‘build’. So im using the appdir parameter of the heroku-deploy.

name: CI

on: [push]

jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        node-version: [14]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node_version: ${{ matrix.node-version }}

      - name: Setup
        run: |
          mkdir -p build/public
      
      <build steps here>

      - name: Deploy to Heroku
        uses: AkhileshNS/heroku-deploy@v3.4.6
        with:
          heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
          heroku_email: ${{ secrets.HEROKU_EMAIL }}
          heroku_app_name: battlographer
          buildpack: heroku/nodejs
          appdir: build

Now when i run my action i get the following error message/logs at the deploy stage

##[group]Run AkhileshNS/heroku-deploy@v3.4.6
with:
  heroku_api_key: ***
  heroku_email: ***
  heroku_app_name: ***
  buildpack: heroku/nodejs
  appdir: build
  branch: HEAD
  dontuseforce: false
  usedocker: false
  docker_heroku_process_type: web
  delay: 0
##[endgroup]
Created and wrote to ~/.netrc
Successfully logged into heroku
Added git remote heroku
heroku: Press any key to open up the browser to login or q to exit: 1/66 (0) [0]
2/66 (1) [0]
...
66/66 (65) [0]
No new revisions were found
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/***.git
 ! [remote rejected] master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/***.git'

            Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch. 
            (If you want to avoid this, set dontuseforce to 1 in with: of .github/workflows/action.yml. 
            Specifically, the error was: Error: Command failed: git push  heroku `git subtree split --prefix=build HEAD`:refs/heads/master
1/66 (0) [0]
...
66/66 (65) [0]
No new revisions were found
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/***.git
 ! [remote rejected] master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/***.git'

        
1/66 (0) [0]
...
48/66 (47) [0]
##[error]Error: Command failed: git push --force heroku `git subtree split --prefix=build HEAD`:refs/heads/master
1/66 (0) [0]
...
66/66 (65) [0]
No new revisions were found
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/***.git
 ! [remote rejected] master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/***.git'

49/66 (48) [0]
...
66/66 (65) [0]
No new revisions were found
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/***.git
 ! [remote rejected] master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/***.git'

Any idea whats going on here?

From some googling it looks like maybe it could be a login issue with heroku, or possibly an issue with remote branch creation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lexwebbcommented, Aug 1, 2020

Thanks for the suggestion, it almost worked! I also was required to set the git username and email for the commit, of which i used some dummy values:

      - run: git config user.email "battlographer@github.com"
      - run: git config user.name "Github"
      - run: git add -A && git commit -m "Updated code"

It is also worth mentioning i had to ensure the folder i was building into was not git ignored.

Thanks for the great action!

0reactions
OmarSalah26commented, Jun 28, 2021

I solved it ,

by create runtime.txt file and put on this file python-3.7.11 as the version of python i want

app.py Procfile requirements.txt runtime.txt

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git push error '[remote rejected] master - Stack Overflow
The error message error: refusing to update checked out branch: refs/heads/master is emitted by the remote repository and it means you're trying to...
Read more >
How to Fix 'failed to push some refs to' Git Errors - Komodor
A commit gets rejected and causes a failed to push some refs to error because the remote branch contains code that you do...
Read more >
Set Git branch security and permissions - Azure Repos
Set permissions for Git branches in Azure DevOps Services/TFS. ... Force push (rewrite history, delete branches and tags).
Read more >
PyCharm - Commit and push changes to Git repository
When you run push, Git will refuse to complete the operation if the remote repository has changes that you are missing and that...
Read more >
GIT : Resolving " Code push Rejected " - YouTube
GIT is most used code repository. Problem Statement :Sometimes, we forget to pull before Push. In such scenario, if commit has been done...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found