Heroku: how to “git pull” after 'git push -f'

I got this error message (copied below) after trying to push to Heroku. I initially set up a facebook canvas app and selected the hosting on heroku options. It gave me a heroku url, which I added as a remote on the app I was developing on my machine

heroku git:remote -a desolate-springs-1684

But when I pushed, I got this error

  • Why does 'git status' ignore the .gitattributes clean filter?
  • How to list all files in a single Git commit with a specific text change in the diff?
  • Unstaged changes immediately after cloning in Eclipse
  • Read current git branch natively using vscode extension
  • How can I overwrite, not merge, one remote branch into another branch?
  • Git in Android Studio disappeared?
  • error: failed to push some refs to 'git@heroku.com:desolate-springs-1684.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.
    localhost:nhl michaelmitchell$ 

    So I did

    git push -f heroku master

    But now I apparently have to do a ‘git pull’. However, what do i put after the ‘git pull’? The name of the heroku url? or something else?

  • Is possible to push the non-pushed commits if the git files contain corrupt loose objects?
  • Converting file (tracked with Git) from Java to Kotlin in Android Studio
  • Manage http access to git repositories using gitosis
  • bzr: Softly undo last commit
  • How to share git branches that are based on same repository?
  • Script to find all TODO comments created on a git branch?
  • 2 Solutions collect form web for “Heroku: how to “git pull” after 'git push -f'”

    Forcing your git push was not a good idea because you lost any commit that was done by you or other collaborators you were missing on your working copy.

    Before pushing, you should have either merged or rebased the upstream changes into your local working copy.

    To merge the changes locally

    $ git pull heroku master
    $ git push heroku master

    To rebase the changes locally

    $ git pull --rebase heroku master
    $ git push heroku master

    BTW, now that you have pushed your changes, you actually don’t need to do anything else. The remote repository already contains all your changes.

    If for whatever reason the $ git status command is returning outdated references, simply run

    $ git pull heroku

    to fetch all the remote changes. Please note that unless you specify a target branch (or you have the tracking branch enabled), git pull will simply download (and not merge) the upstream changes.

    Also note that Heroku should not be considered a git hosting. It means that it’s extremely uncommon to perform a git pull from Heroku. Instead, you should use a git hosting (such as GitHub or BitBucket) to store your repository and only perform push to Heroku to deploy the application.

    That error basically means that there is code in the repo that is newer than the code you’re trying to push to it.

    you have to do a pull and update your own working repository then push again, or just force a push

    git pull heroku master

    As a side note, if you aren’t familiar with all the git commands, I would recommend you use a GUI as it may make the whole process a lot less overwhelming.

    There are plenty of great clients here: http://git-scm.com/downloads/guis

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