Is there a way to delete a branch on heroku - ruby-on-rails-3

I am using heroku to host my application. With merges and rebases i got 2 different stages of my app.
Local master is different from master on heroku.
pushing to heroku master failed with:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#heroku.com:xxxxx.git'
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
is there a way to delete the heroku master?
then i can push it again to heroku master..

You can force push
git push --force origin master
That will overwrite remote master.
You can also delete remote branch by doing this
git push origin :master
Note the colon before branch name. This command says "take void from local machine and put this instead of remote branch 'master'"

In my case, I renamed the branch on Heroku from master to main, and I want to delete the old master branch. If I delete the remote master branch directly on Heroku, it will be rejected.
The only way I found working is based on this document to reset.
Assume your app name is my-app. You can reset by
heroku plugins:install heroku-repo
heroku repo:reset --app=my-app
Note this will remove all branches in Heroku. So you need push to Heroku again by
git push heroku main

Related

Heroku deployment was failed due to concurrent builds limit

I deploy heroku server and link to Github.
when I change my code, I git add . -> git commit ->
after then, I did:
git push origin master && git push heroku master
origin master is for Github, heroku master is for Heroku.
I guess it was fine to just git push origin master since it was already linked to heroku.
But I just did both for doing it surely.
However, error mail comes from Heroku:
an automatic deployment failed.
the build failed with the message your account has reached its concurrent builds limit
So what should I do ?
It is okay leave it as it is now?
when I click Compare diff from Heroku.
the last commit appears.

Heroku repo has disappeared when pushing my rails app

I have been using heroku already for my rails app. I have come back to do some more work on the app but when I do
git push heroku master
I get
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
but
git remote -v
gives
origin git#github.com:x/guidelines.git (fetch)
origin git#github.com:x/guidelines.git (push)
So I assume that means that the repo is there somewhere? Any ideas where I'm going wrong?
Yes, don't worry all is fine.
You need to go to heroku.com and get the git URL of your application from the Apps > App Name > Settings page. You're looking for git#heroku.com:<application-name>.git.
Back at your command line readd the heroku remote via;
git remote add heroku git#heroku.com:<application-name>.git
and you'll be then able to push to the heroku remote.

Rails and Git push, Git pull: logs return same commit, changes aren't made

I've got a local branch (master), a GitHub repo (origin), and another remote repo (server). I've set up my remote so locally I can type git push server master and push the changes to server/master.
When I type git log -1 locally and on the server they return the same commit, but none of the changes I made locally are visible on the server.
I deployed my app with Capistrano so redeploying it makes the changes visible immediately, but I don't want to have to redeploy every time I make a change.
Any idea what's going on here? I'm rather new to Git. Hopefully it's something easy to fix.
It sounds to me that you maybe looking at a different directory than your web server is pointed to.
When I setup capistrano:
cap deploy:setup
#then
cap deploy
it creates a directory structure similar to:
/releases (each deploy gets its own randome number directory)
/current (a sym-link to the latest release)
/shared
None of these folder are tied to git. Which makes me think your webserver may not be pointed to the same directory that you're using with git.
--
You may find cap deploy is preferable as you'll be able to see the output if there are any issues.
I'm not a huge expert but the above is how I've setup rails with Capistrano.
Normally origin is the name used for the GitHub remote and not master. You can check what remotes you have by doing git remote show. If you want even more detail on the remote use git remote show origin (or whatever your remote is called, if it is not origin). This will give you a list. I suspect that what you have is actually two local branches (master and server). Try doing a git push server origin. This will take your server branch and put it on GitHub.
Alternatively
If you are trying to combine the changes in your server branch with your master branch then use checkout master and then git merge server. This will merge your changes from the server branch into your master branch and you can then upload to GitHub via git push master origin.

deploying to a test server before production on heroku

As I am new at this, I am not sure if this is how it should be -
I am making a webapp and using heroku for hosting
I want to have several developers working on the same code on github.
I'd like to have 2 servers on heroku - one for production and one for testing(is it also called staging?)
problem is I know what by doing git push heroku master from the webapp folder it will send it to the application to the heroku server which was setup in the first place.
How do I deploy to 2 different heroku instances from the same folder using git? Is it possible/ recommended?
When I push to github it's usually the master, should I have another branch for test?
Is there a way to transfer an app between heroku instances?
if there's a place where there is a recommended deployment routine for heroku and github I'd be happy to read it
When you run git push heroku master 'heroku' identifies the remote repository you are pushing to. In your case 'heroku' seems to be a reference to your production server. Similarly you probably have an 'origin' remote pointing to github.
If you list your git remotes you'll probably see something like this:
> git remote -v
heroku git#heroku.com:heroku_app_name.git (fetch)
heroku git#heroku.com:heroku_app_name.git (push)
origin git#github.com:your_github_org/repo_name.git (fetch)
origin git#github.com:your_github_org/repo_name.git (push)
To push to a different heroku app you can just add that app as a new git remote.
git remote add heroku-staging git#heroku.com:heroku_staging_app.git
Now you should be able to push to either remote as needed.
git push origin master //push to github
git push heroku-staging //deploy to staging
git push heroku master //deploy to production
In general I suggest that you should not be pushing to heroku manually. Hopefully you can have a continuous integration server watch github, run tests whenever you push changes, and deploy to staging only when your automated tests pass. You can then have a manually triggered CI task which pushes whichever commit is currently on staging to production as well (or even automate production deploys as well).
You can perform the same configuration using the heroku command line. That also gives you a good way to manage environment variables and other settings on both of your heroku apps:
https://devcenter.heroku.com/articles/multiple-environments

Heroku -- push not working

So I used heroku create with one of my apps, but then when on heroku.com I deleted the corresponding repository. I tried using heroku create again and it did give me another URL, but now when I try to push my app it keeps looking for the old one:
! No such app as [old name]
fatal: The remote end hung up unexpectedly
How do I get heroku to stop looking for this old app and use the newly created one?
Your local git repository has the old URL saved in its heroku remote. You have to update it using
git remote set-url --push heroku git#heroku.com:new_app.git
See Heroku's documentation and the Git manpage for more information.