Deploying to Heroku using git on bitbucket

GitHerokuGithubBitbucketHeroku Toolbelt

Git Problem Overview


I want to host my source on bitbucket using git because I obviously get a free private repo and I want to host my app on heroku using the source code from bitbucket.

Can i do it using the github client and heroku toolbelt. Will it work? Github is great but i dont want everyone seeing my code and I dont want to pay for a private repo because its a small project.

Git Solutions


Solution 1 - Git

Deploying to Heroku should work regardless of where you host your code as the Heroku CLI adds it's own git remote for the sake of deployments. In fact, you can even git pull from Heroku, so you could technically use Heroku as a private git repository instead (though not recommended). As for using the GitHub client to connect to bitbucket, simply change the repository remote to the URL provided by bitbucket in the settings tab of the client.

Solution 2 - Git

Just to add to zeiv's answer who said it should work: I can confirm that it does. We use bitbucket for git hosting and deploy to heroku. What you can't seem to do is add your bitbucket repo to your heroku account to have commit history show up, this feature seems to be currently limited to github (heroku's fault ;-)

Solution 3 - Git

Bitbucket supports now Pipelines, which should make it pretty easy to deploy on Heroku. Just follow this tutorial: https://confluence.atlassian.com/bitbucket/deploy-to-heroku-872013667.html

My bitbucket-pipelines.yml to just push the master branch to Heroku looks like this:

image: node:6
clone:
  depth: full
pipelines:
  branches:
    master:
      - step:
          script:
            - git push -f https://heroku:[email protected]/$HEROKU_APP_NAME.git $BITBUCKET_BRANCH

Solution 4 - Git

Chiming in with Stefan - this works perfectly. Here's what I did:

  1. Got really frustrated with the way my WP blog was resetting daily, presenting anyone who navigated to http://blog.example.com with a setup screen, because there was no wp-config.php.
  2. Logged into bitbucket.org.
  3. Linked my bitbucket & github accounts.
  4. Forked my "wp-blog" repo from github, which I had previously linked to my heroku remote.
  5. Cloned into this new fork ("git clone https://[email protected]/myname/wp-blog_config.git";) .
  6. Added a proper wp-config.php.
  7. Added my heroku remote from within this new fork ("git remote add heroku [email protected]:adjective-noun-1234.git")
  8. Committed & deployed to heroku ("git push heroku master:master")

Solution 5 - Git

If you dont want to work in the command line and push to heroku the whole time and worry about maintaining SSH keys (quite annoying if you work on different boxes), then follow this guide on how to setup continuous integration using codeship. Its a free plugin on heroku.

http://blog.codeship.io/2014/04/29/continuous-deployment-heroku-bitbucket-nodejs.html

Solution 6 - Git

I found this [Page][1] helpful

Install [Heroku Toolbelt][2]

[1]: https://dashboard.heroku.com/apps/places-view/deploy/heroku-git "page" [2]: https://toolbelt.heroku.com/

If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.

$ heroku login

Create a new Git repository

Initialize a git repository in a new or existing directory

$ cd my-project/
$ git init
$ heroku git:remote -a PROJECTNAME

Deploy your application

Commit your code to the repository and deploy it to Heroku using Git.

$ git add .
$ git commit -am "make it better"
$ git push heroku master

Existing Git repository

For existing repositories, simply add the heroku remote

$ heroku git:remote -a PROJECTNAME

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWasswa SamuelView Question on Stackoverflow
Solution 1 - GitXavierView Answer on Stackoverflow
Solution 2 - GitStefanView Answer on Stackoverflow
Solution 3 - GitKarl AdlerView Answer on Stackoverflow
Solution 4 - GithandwovensoleView Answer on Stackoverflow
Solution 5 - GitPieter VenterView Answer on Stackoverflow
Solution 6 - GitKarim SamirView Answer on Stackoverflow