-1

There are many questions like this on StackOverflow but I can't seem to find the one that fits me uniquely. Git won't push, the error message says error: failed to push some refs to 'https://git.heroku.com/aydansheightapp.git' Not sure how to proceed from here, I need to properly deploy my app but I'm a code newbie and have been stuck in this stage. Thanks for your help & patience!

aydanaslanova@Aydans-MacBook-Pro ~ % heroku git:remote --app aydansheightapp
set git remote heroku to https://git.heroku.com/aydansheightapp.git
aydanaslanova@Aydans-MacBook-Pro ~ % git push heroku master
To https://git.heroku.com/aydansheightapp.git
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://git.heroku.com/aydansheightapp.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  • Does this answer your question? [git: updates were rejected because the remote contains work that you do not have locally](https://stackoverflow.com/questions/24357108/git-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-have) – phd Apr 15 '20 at 16:46
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+remote+contains+work+that+you+do – phd Apr 15 '20 at 16:46

1 Answers1

0

The error message is telling you the problem:

hint: Updates were rejected because the remote contains work that you do ... You may want to first integrate the remote changes (e.g., 'git pull ...') before pushing again

The remote branch has moved on since you pulled it. You need to incorporate your code into this branch before you can push it up.

To bring this work into your branch issue the following commands:

git fetch
git rebase origin/master

Then issue your git push heroku master command again.

simon-pearson
  • 1,601
  • 8
  • 10
  • This is what it returns: First, rewinding head to replay your work on top of it... error: The following untracked working tree files would be overwritten by checkout: script.js Please move or remove them before you switch branches. Aborting fatal: Could not detach HEAD – aydanaslanova Apr 15 '20 at 16:50
  • Did you just create `script.js`? Issue the following command to commit `script.js`: `git add -A && git commit -m "Adding script.js"`. Then run the above commands. – simon-pearson Apr 15 '20 at 16:52
  • No, I don't need that file. Idk how it got there. – aydanaslanova Apr 15 '20 at 16:55
  • That didn't fix it, still getting the same error. I'm thinking maybe git push --force? – aydanaslanova Apr 15 '20 at 17:04
  • If it's your repository with only you working on it then that's fine, however in general I'd advise against doing that because you might overwrite a team-mates work. In general forceful pushing is a risky business. – simon-pearson Apr 15 '20 at 17:37