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.

Error on pushing to heroku

See original GitHub issue

I’m using this action and I have the following error message while the aciton tries to push to heroku.

remote: !	Push rejected, source repository is a shallow clone. Unshallow it with `git fetch --all --unshallow` and try pushing again.
remote:
To https://git.heroku.com/laborsord.git
 ! [remote rejected] HEAD -> master (shallow update not allowed)
error: failed to push some refs to 'https://git.heroku.com/laborsord.git'
##[error]Error: Command failed: git push heroku HEAD:refs/heads/master

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AkhileshNScommented, Jan 26, 2020

Alright so to fix this problem, all you wanna do is switch the version of actions/checkout from v1 to v2 and remove the fetch-depth option

# ...
jobs:
  build:
    steps:
      - uses: actions/checkout@v2 # from v1 and no with: fetch-depth: 0
# ...

And to try and explain to you the problem, originally in v1 of the actions/checkout, the action was making a complete clone of the repo (or an unshallow clone) but later on in v2, the team at github decided to make the action perform shallow clones instead (and that’s what started this issue in the first place). So to try and circumvent this, I decided to add the

git fetch --prune --unshallow

command as built into this action’s (heroku-deploy) code. But now the action only works on shallow clones 😅 (since the action makes them unshallow anyway). I did this because I suspected most people would use v2 of the actions/checkout action and wouldn’t think to add the fetch-depth: 0 flag so by having unshallowing built into the heroku-deploy action, they wouldn’t even need to think about it. But its pretty clear now I’ll need to work on a more elegant situation which I will do in the next release.

FOR THE TIMEBEING THOUGH, FOR ANY FUTURE USERS RUNNING INTO THIS ISSUE, make sure that you are using v2 of the actions/checkout action and you have not set the fetch-depth: 0 flag exactly as given in the documentation. I’m gonna try adding the shallow and unshallowing issues in the docs as well (atleast until I can find a way to circumvent it)

P.S @balexandre sorry for the late reply, I suspect we live in different timezones and I was asleep when you commented

1reaction
AkhileshNScommented, Jan 13, 2020

Actually I think I found the problem, in the official docs for the actions/checkout@v1 github action, it says

fetch deep

The second line says that by default, the action only fetches one commit. That could be the reason why the clone is coming off as a shallow one. To fix this, try adding the following line in your main.yml inside your .github/workflows folder:-

name: Deploy

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v1
          with:             # ADD THIS LINE
            fetch-depth: 0  # ADD THIS LINE
        - uses: akhileshns/heroku-deploy@master
          with:
            heroku_api_key: ${{secrets.HEROKU_API_KEY}}
            heroku_app_name: "YOUR APP's NAME (must be unique to heroku)"
            heroku_email: "YOUR EMAIL"
            buildpack: "SOME BUILDPACK [OPTIONAL]"

And hopefully that fixes it

Read more comments on GitHub >

github_iconTop Results From Across the Web

I cannot push to Heroku git. I see an error starting with fatal
When pushing my code to Heroku git through its HTTPS URL, I see an error like fatal: protocol error: bad line length character:...
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 >
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 getting error when I am trying to run: git push heroku master
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. remote: See https://devcenter.
Read more >
Heroku deploy failure - Top 3 error newbies always have
When you deploy failed a simple app to Heroku, you may encounter various types of error. This video is a guide to fix...
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