简体   繁体   中英

Heroku app seems to be pulling from wrong Git respository/branch

My problem seems to be due to my lack of understanding with how Git and Heroku communicate, but here it is:

I have/had two Heroku apps running fine for the same project - one staging and one production. Originally, I had both apps connected to the same master branch in my Git repository. I'd just push all staging changes up to the staging app with git push heroku-staging master , and when I wanted to push up to the production app, I'd just run git push heroku master .

For clarity, these are my remotes. I replaced my app with my-app :

heroku  https://git.heroku.com/my-app.git (fetch)
heroku  https://git.heroku.com/my-app.git (push)
heroku-staging  git@heroku.com:my-app-staging.git (fetch)
heroku-staging  git@heroku.com:my-app-staging.git (push)
origin  git@github.com:My-app/my-app.git (fetch)
origin  git@github.com:My-app/my-app.git (push)

And here are my branches:

dev           cbafa55 added new badge
master        cb5f4c4 split seeds into different services
* staging       cbafa55 added new badge

Recently, I realized I should keep all my staging changes in a separate staging branch on my repository, and keep my production environment at one spot in the master branch.

So I'm now using a staging branch in the repository (which already existed but wasn't being used) for everything I want to throw up to the staging app, and the master branch will be used for the production app.

I had some trouble getting the staging branch to match what I have locally, so I just used git reset --hard (commit_id) , where the commit_id was the last commit I made that I was satisfied with. So at this point, my staging branch in the git repo matches perfectly with where I want it, and I confirmed on github, to make sure everything on the staging branch is the same.

But when I push up to heroku-staging now, it seems to still be pulling from the master branch. Even though I'm currently in my staging branch, and pushing from there. I added everything, and committed everything, but when I push it up, it tells me everything is up to date, and on my staging app, I see a fairly old familiar error in the logs (just something I remember screwing up in the application itself). When I look at my staging branch, though, it doesn't have the code that produces that error. However, my master branch does still have the code that produces that error (since I haven't pushed to the master branch in a while).

I've tried using git push heroku-staging staging , and git push heroku-staging master , both from my local staging branch (which has all my current changes), both of which yield a message that says everything is up to date. I'm not sure exactly how heroku apps make the connection to branches, but these are the only two options I can think of.

I also looked at the activity of my app on the heroku dashboard, and it says the most recent build was successful, and deployed cb5f4c4 , which is the most recent commit from my master branch (which I don't want). This makes sense, my heroku-staging app is producing that error that exists on the master branch, but I'm not sure why it's using this commit.

Apologies for the novel of a question, but just wanted to be thorough with the things I've done/tried.

I've hit a wall, and can't think of any more ideas. Any thoughts?

If you want to push the changes in your staging branch to your Heroku staging site configured as git remote heroku-staging you need to do:

git push heroku-staging staging:master

Heroku will only deploy the master branch so you need to push your local staging branch to the remote master . It looks a little weird but this is just the git command for pushing a local branch into a different remote branch.

Seems like you need this:

git push heroku-staging staging:master

which will push all the changes from your local staging branch into your remote master of heroku-staging .

See this stackoverflow post for more information about how to push different local git branches to heroku.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM