Michael Francis
Michael Francis

Reputation: 8757

Heroku: 'Push rejected, repository is empty' on Cloud9 IDE

I'm working on Cloud9 IDE, and I just attempted to deploy to Heroku, but I got this error:

[1/5] Verifying preconditions...
[2/5] Updating repository...
[3/5] Pushing to Heroku...
1:: Warning: Permanently added the RSA host key for IP address '50.19.85.154' to the list of known hosts.
!     Push rejected, repository is empty
To [email protected]:anthro-site.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:anthro-site.git'

I looked around and found a few questions here that are similar, such as this one, but unfortunately the answer to that question requires me to install software, and I don't think I'm allowed to do that on Cloud9. I don't seem to have access to the heroku command, so it must not have been installed for me. How do I proceed?

Upvotes: 2

Views: 809

Answers (2)

MaltMaster
MaltMaster

Reputation: 758

https://devcenter.heroku.com/articles/git#deploying-code

Branches pushed to Heroku other than master will be ignored by this command. If you’re working out of another branch locally, you can either merge to master before pushing, or specify that you want to push your local branch to a remote master. To push a branch other than master, use this syntax:

$ git push heroku yourbranch:master

It worked for me.

Upvotes: 0

Michael Francis
Michael Francis

Reputation: 8757

Apparently you can install the Heroku client on Cloud9, as described here:

To deploy to Heroku, type the following commands:

wget http://assets.heroku.com/heroku-client/heroku-client.tgz
tar xzfv heroku-client.tgz
cd heroku-client/bin
PATH=$PATH:$PWD

Now, you can use the heroku command for your projects, as described in the Heroku documentation.

But that wasn't my problem. It seems in order to push to heroku, you must be on your master branch. The steps for me were as follows:

$ git checkout master
$ git merge dev # that's the branch I was working on
                # if you don't merge, master will not have whatever
                # commits you've made to the branch you were on.
$ git push --set-upstream heroku master

after that I waited for Heroku to finish installing my app, and now I can access it.

Upvotes: 2

Related Questions