Reputation: 15374
I am collaborating on a project and cloned the repo from Github, made some changes and pushed to Heroku. Now the cloned app had all of its keys and passwords hardcoded, not in ENV variables.
So I created ENV variables, added the file to .gitignore. So this app still has these keys in the commit history. What I have done now is have the author create a new repo on Github, remove .git file from original app and push new code to new repo.
So now I have cloned the new app, added a new remote the the Heroku app.
heroku git:remote -a myapplication
My issue is I cannot push the new app to the existing Heroku app. When I do I get:
error: failed to push some refs to '[email protected]:myapplication.git
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
So a git pull
says everything is up to date.
git remote -v
outputs
heroku [email protected]:myapplication.git (fetch)
heroku [email protected]:myapplication.git (push)
origin [email protected]:author/myapplication.git (fetch)
origin [email protected]:author/myapplication.git (push)
What can I do to push the new application to the existing heroku app?
I ran
git push -f heroku master
which pushed but I had error
you have not declared a Ruby version in your Gemfile.
To set your Ruby version add this line to your Gemfile:"
ruby '1.9.2'"
I've never had to specify before, and now all the original config vars that where set are no longer stored in Heroku.
Upvotes: 1
Views: 1847
Reputation: 5018
Git uses the concept of tracked branch to know which remote branch is linked to a local branch.
In your case, you probably have your local branch (I suppose it's master
) linked to origin/master
. So, when you do a git pull
, Git is trying to get new stuff from [email protected]:author/myapplication.git
, which is not the wanted behavior.
You have to change your tracked branch using :
git branch --set-upstream-to heroku/my_branch
Then, you can do a git pull
which will now have the wanted behavior. Then just push to heroku, as you always do.
Upvotes: 1
Reputation: 1323373
git pull
would pull by default from GitHub, which has all your commits already.
You might need to:
git pull heroku
origin
heroku
through the heroku
command.Upvotes: 3