Deploying to heroku with git keeps getting rejected due to fast-forwards

I keep getting the following fail with heroku + git

$ heroku jammit:deploy --app XXXXXXXXXXX
===== Compiling assets...[OK]
===== Commiting assets...[OK]
===== Done...
===== Deploying assets for xxxxx-staging to heroku...
To git@heroku.com:XXXXXXXX.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:xxx-staging.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
[FAIL]
===== Done...
===== Deleting compiled assets...[OK]
===== Commiting deleted assets...[OK]
===== Done...
$ git pull
Already up-to-date.

Any ideas what I’m doing wrong or should be doing differently to allow for pushing without having to force a push?

  • Alias for keeping feature branch in sync with “develop” branch
  • Git-tracked Folder Within a Git-tracked Folder
  • Getting rid of “git: /usr/local/lib/libz.so.1: no version information available (required by git)”
  • Changing Git remote URL updates fetch but not push
  • Deleting remote branches?
  • Git: How to search for a deleted file in the project commit history?
  • Thanks

  • Files lost after checkouting out to the other branch
  • Convert spaces to tabs in lines I changed in a commit
  • .git/info/exclude replacement for git submodule?
  • git ls-files in bare repository
  • ignore all _notes directories with GIT
  • Apply git merge stategy only on one file?
  • 3 Solutions collect form web for “Deploying to heroku with git keeps getting rejected due to fast-forwards”

    Just force the commit every time you push and it will push it even if there are fast-forward commits. We do this in our development Heroku server all the time since we’re all pushing different commits (some further behind than others).

    git push -f git@heroku.com:picasso-staging.git
    

    I don’t use jammit for deploying, but you could probably get away with force pushing first and then running the jammit task second. Or check and see if jammit supports a force push flag of some sort.

    git push -f REMOTE BRANCH:master #or just master
    

    Force it! Replace REMOTE with your heroku remote name (git remote -v to view all remotes). Replace BRANCH with the branch you want to push or just put “master” for the master branch.

    The problem is that changes have already been pushed and your commit is behind those newer pushes. I’m going to assume you have a master branch and your feature branch still, let’s say it’s called my_feature. You can do this and be okay:

    git checkout master
    git pull
    git checkout my_feature
    git rebase master
        (you may have to fix some conflicts here, if any are found)
    git checkout master
    git merge my_feature
    git push heroku
    

    You should remember to run any tests you have to make sure everything’s good still.

    Git Baby is a git and github fan, let's start git clone.