pushing temp changes to heroku and then removing them (from git) - ruby-on-rails

Sometimes I end up with something I need to debug in my rails app on Heroku. For example, I might output some debug info in a view. Currently, I'll make the changes in my code, commit it to git, then push it up to heroku. Once I'm finished I'll remove the debug code, commit, push to heroku again. The problem is that my git history gets cluttered with this mess. Since my temp code got pushed to heroku I can't change the git history using rebase.
Is there a way to do this and clean up my git history?
Please keep in mind my question is really about how to revert the temp changes I made so they do not show up in my git history.

The easiest way is to branch off your debug code using git branch debug then git checkout debug. From there, you can push that to Heroku with the command git push heroku debug:master. When it's time to back that out of the codebase, you git checkout master, git push heroku master --force, to overwrite the debugging code on Heroku, and git branch -D debug to remove the debug branch.

Related

Heroku rollback and pulling older release

I did a mistake in the code and pushed it in to heroku master. I am not able to identify the problem in the code I have locally. I did a heroku rollback to previous version - it worked and previous version is visible on heroku.
However I am struggling to pull the code (as heroku clone:app name gives me an old code). I tried heroku releases to get the release number which I then used for git pull heroku af5c366b, however getting err:
fatal: Couldn't find remote ref af5c366b
How can the code be restored?
I am completely now to Heroku.
You should be able to simply run...
$ git checkout af5c366b
Which should bring you to a "detached head" state with this helpful message..
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Once you checkout the branch you can merge that branch into master.
$ git checkout master
$ git merge new-branch-name

git heroku not download collaborators recent push

A collaborator on a heroku app Im working on pushed some code, moments before I made a push, as the owner I rolled back the app, but now I can not seem to download the code to the my local repository?
I've tried rebasing the branch, fetching and reseting the HEAD, everything said it is up todate? I even deleted the whole local repository as a last resort and clones the app, is rolling it back in Heroku causing the problem?
When I do heroku releases I try to git checkout <deploy of collaborator> and I get a pathspec error
can`t you see his commit in reflog (git reflog)? if it is the case ask him to push again or push to a feature branch and cherry pick the commit you needed in to your branch

git push heroku master - no error messages but changes not displaying on web app

After installing the devise gem to create users on my web app, my changes are not appearing on the live app.
I believe I am running the correct code in terminal (I am following the one-month-rails course):
$ git add .
$ git commit -am "message"
$ git push
$ git push heroku master
The push to heroku runs through and I don't receive an error message, however, when I try to access my heroku page
$ heroku open
The changes are not displayed on the live web-app.
All the changes are displayed when running the rails server on the localhost. Furthermore, the activity log on the heroku website shows that my push went through and that its running the same version as my most recent push to github.
Any thoughts?
Best,
Brian
** Also posted this response here: git push heroku master says "Everything up-to-date", but the app is not current
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!
I could resolve my issue only by making a new_branch and pushing that on heroku:
git checkout -b new_branch
git add .
git commit -m "Just a test commit to push new branch to heroku"
git push heroku new_branch:master
heroku restart
You should take care of following things when you have your hands on heroku
run pending migrations if any heroku run rake db:migrate
restart your heroku app after successful run of migrations heroku restart not needed if you have only code changes, but a good practice to do.
verify assets are getting compiled properly on a push, if not you can heroku run rake assets:precompile

Heroku doesn't see my changes after git push

I am trying to deploy a new version of my app to heroku and although running it locally works, I can't see any change after I do the following:
git push heroku master
and then
heroku run rake db:migrate
There seems to be no effect. It's strange because without a model change I was able to deploy changes with just the git push command. Any thoughts?
It sounds as if you might be not commiting your changes to Github first.
git add .
git commit -m "commit details here"
git push origin master
THEN
git push heroku master
If you're pushing and then migrating you then need to do
heroku restart
to have your application recache the DB schema.
I had the same issue and posted what worked for me in response to others' similar issues:
$git push heroku master - no error messages but changes not displaying on web app
git push heroku master says "Everything up-to-date", but the app is not current

Heroku: how to "git pull" after 'git push -f'

I got this error message (copied below) after trying to push to Heroku. I initially set up a facebook canvas app and selected the hosting on heroku options. It gave me a heroku url, which I added as a remote on the app I was developing on my machine
heroku git:remote -a desolate-springs-1684
But when I pushed, I got this error
error: failed to push some refs to 'git#heroku.com:desolate-springs-1684.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
localhost:nhl michaelmitchell$
So I did
git push -f heroku master
But now I apparently have to do a 'git pull'. However, what do i put after the 'git pull'? The name of the heroku url? or something else?
Forcing your git push was not a good idea because you lost any commit that was done by you or other collaborators you were missing on your working copy.
Before pushing, you should have either merged or rebased the upstream changes into your local working copy.
To merge the changes locally
$ git pull heroku master
$ git push heroku master
To rebase the changes locally
$ git pull --rebase heroku master
$ git push heroku master
BTW, now that you have pushed your changes, you actually don't need to do anything else. The remote repository already contains all your changes.
If for whatever reason the $ git status command is returning outdated references, simply run
$ git pull heroku
to fetch all the remote changes. Please note that unless you specify a target branch (or you have the tracking branch enabled), git pull will simply download (and not merge) the upstream changes.
Also note that Heroku should not be considered a git hosting. It means that it's extremely uncommon to perform a git pull from Heroku. Instead, you should use a git hosting (such as GitHub or BitBucket) to store your repository and only perform push to Heroku to deploy the application.
That error basically means that there is code in the repo that is newer than the code you're trying to push to it.
you have to do a pull and update your own working repository then push again, or just force a push
git pull heroku master
As a side note, if you aren't familiar with all the git commands, I would recommend you use a GUI as it may make the whole process a lot less overwhelming.
There are plenty of great clients here: http://git-scm.com/downloads/guis

Resources