86

I have an app on Heroku that is running old code. I've made a small change and committed the change. I then ran

git push heroku master

It'll say

Fetching repository, done.
Everything up-to-date

But if I go and look at the app, it's all old code. I did revert the site back to another version in Heroku about 15 days ago, but pushed updates to it since then and they worked.

Why is heroku not getting the most current files from my github repository? Is there a way to just reset the app and push the files from github again? I have production data in the database so I do NOT want to touch it.

starball
  • 20,030
  • 7
  • 43
  • 238
Darkmatter5
  • 1,189
  • 3
  • 12
  • 19
  • 3
    Same problem here. Did you ever figure it out? Answers offered here are obvious things that I've already tried to no avail. @Darkmatter5 – Ben Nov 08 '14 at 19:56
  • 1
    Answers say that I might be on another branch, but I'm experiencing the same problem and my branch is master. Locally I had changed, successfully deployed them on heroku, and git says that there is no difference between local and heroku while changes were NOT actually showing (the browser still displays old version before deploying). I've cleared both client and server caches and the problem persists. – Clarity Aug 14 '20 at 15:17

14 Answers14

102

Kindly confirm your current branch is master.

 git branch 

If the pointer is not pointing the master, then check out to master branch

git checkout master

Commit your changes and try to push to heroku

git commit -am "xxxyyzzz"    
git push heroku master
Kannan S
  • 2,459
  • 1
  • 17
  • 17
74

When you run git push heroku master, git is assuming that you are pushing from master, so if you changes are in other branch, you will try to push your master branch without changes.

You have two options

1.Merge your changes with master and push them.

Commit your changes in your actual branch, then merge them with master

git commit -a - m "your messages"
git checkout master
git merge your_feature_branch
git push heroku master

2.Push your changes from your actual branch

git push heroku your_feature_branch:master
levi
  • 22,001
  • 7
  • 73
  • 74
23

I had a similar issue and by no means my changes were visible on heroku. To reconfirm myself I even took a clone from heroku and it was obviously up to date.

I could resolve my issue only by following this approach:

Step 1: Make a new branch from master

git checkout -b new_branch

Step 2: Just add a comment in any file to make a new commit and then:

git add .
git commit -m "Just a test commit to push new branch to heroku"

Step 3: Push the new branch to heroku.

git push heroku new_branch:master
heroku restart

You could now see your changes successfully on heroku.

techdreams
  • 5,371
  • 7
  • 42
  • 63
13

I'm willing to bet you've forgotten to run git add . followed by git commit -m 'xyz'?

stephenmurdoch
  • 34,024
  • 29
  • 114
  • 189
  • Heheheh, this made me laugh. After coding three days and night for fixing little things, I forgot to add and commit my code – RegarBoy Dec 12 '16 at 16:04
6

When this happens, I push previous commit hash to master like this:

git push some-heroku-app-name SOME-COMMIT-HASH:master --force

Then I re-push master like this:

git push some-heroku-app-name master:master
Vladimir Djuricic
  • 4,323
  • 1
  • 21
  • 22
  • 1
    I used this when needed to rebuild after changing the build pack on heroku. You probably need to add `--force` to the first command. – Markus Jul 27 '18 at 08:46
  • @Markus Actually, I never needed "--force". It doesn't hurt to have it so I've updated my answer. Thx! – Vladimir Djuricic Aug 02 '18 at 12:25
5

Even though this is an old issue, I wanted to update with what worked for me (a newbie) should anyone else run into this:

After following the instructions here (from Hudson), what finally did the trick for me was doing a "git pull" after checking out the "master" branch. Perhaps "git push heroku master" pushes out only the local branch of master?

Of course, this assumes all required changes have been correctly merged into your master. I hadn't pulled from master on my local since the project set up because all merges (from development to master) were handled on GitHub and I had been working on new branches that were later merged with development.

So, to restate steps above from Hudson:

git checkout master

git pull

(here, I updated README to have a change to commit, like "Heroku deploy [date, time]"

git add .

git commit -am "xxxyyzzz"

git push heroku master

heroku run rake db:migrate

heroku restart

Good luck!

Milena
  • 113
  • 1
  • 5
4

I noticed it only works when you specify the local branch:

git push heroku <local_branch_name>:master
Tiago Barroso
  • 329
  • 4
  • 4
3

Try:

heroku status

This returned the following, which confirmed that the problem was with the heroku API (and not with my app!):

"The API is experiencing delays. This may result in delays with adding new domains, new releases, and other such actions. Currently, engineers are investigating the issue."

stevec
  • 41,291
  • 27
  • 223
  • 311
2

Same issue, I added a remote to my local repository with the heroku git:remote command and then pushed it.

heroku git:remote -a your-heroku-app

git push heroku master
1

I know, I know, silly, but it happened to me so I'm leaving a warning to others: make sure the app you're pushing to is the same app you're checking for changes.

In my case I was pushing to staging and then running a shell on production and not understanding why the static files didn't change.

(It started with a real issue where static files didn't change when I pushed a new version, but it was probably a one-push fluke, and it only kept me going in circles for another hour because I was testing the wrong app.)

Aur Saraf
  • 3,214
  • 1
  • 26
  • 15
  • This was my problem. I did a `git remote -v` to check URLs for my "heroku" (production) remote and my "staging" remote, and they were both the same staging url. So I was pushing to staging twice. I deleted the production url and added the correct remote url from my heroku dashboard to my local app. Thanks! – DC1477 Nov 17 '21 at 10:47
1

If you're using Java, don't forget to rebuild the project before pushing.

In case of Gradle:

gradlew clean install
Ali Bdeir
  • 4,151
  • 10
  • 57
  • 117
  • 1
    Don't know why you got a downvote... I had the same issue but with a React project. Running `webpack -p --progress --config webpack.config.prod.js` (where the last arg is the name of your webpack config file) and then commiting & pushing solved the issue for me. – abagh0703 Aug 07 '18 at 08:58
1

My executable name had changed but I forgot to change the name in my Procfile. So while all the files were updating correctly in heroku, the same old executable was running. I used heroku local from the command line to help track that issue down.

birken25
  • 333
  • 1
  • 2
  • 11
1

If you are pushing code to heroku and you get Already up to date., this means you are in a branch like the development branch but deploying the master/main branch. A solution to this is that pushing using git eg git push heroku main will publish your local main branch and not the development which is ahead in commits. So to fix this just do a merge of development branch to the main branch before pushing to heroku

Felix Orinda
  • 593
  • 4
  • 20
  • To add to this - a solution would be to go to to master branch with "git checkout master", merge another branch if required updates are on it, then simply do "git push" (push to the github repo), and finally "git push heroku master" – Conor Jul 30 '22 at 20:17
0

Had the same issue multiple times. What worked for me if clearing my browser history or opening the app in an incognito window.