Amy Brown
Amy Brown

Reputation: 117

steps to create a second heroku app from the same computer?

I want to create a completely separate app from my computer. Up to this point, I only have on folder that I worked off of which I used git to push my updates to heroku.

How do I go about creating a completely separate heroku app while at the same allowing me to revert back and forth between the two apps?

I want to keep the first app as it is but I want to start developing a second app as a trial with the flexibility to be able to go back and work on the first app and vice versa.

Upvotes: 0

Views: 326

Answers (2)

Amit Kumar Gupta
Amit Kumar Gupta

Reputation: 18567

First, make sure your apps are in entirely separate directories (one shouldn't be a subdirectory of the other). Something like this is typical:

workspace
  |
  |----- my_app_1
  |         |
  |         |---- .git
  |         |       |
  |         |       |---- config
  |         |       |---- ...
  |         |      
  |         |----- app
  |         |----- Gemfile
  |         |----- ...
  |
  |----- my_app_2
  |         |
  |         |---- .git
  |         |       |
  |         |       |---- config
  |         |       |---- ...
  |         |      
  |         |----- app
  |         |----- Gemfile
  |         |----- ...
  |
  |----- ...

So you might have a workspace directory, which contains several Rails application directories my_app_1, my_app_2, etc. And each of those directories are structures like a typical Rails-application-with-git-version-control project.

  • To create a new rails app, cd into your workspace directory, and enter the command rails new my_app_x.
  • To initialize it as a git repository, cd into the newly created my_app_x directory and enter the command git init (followed by a git add .; git commit -m "initial commit").

Finally, you need to make sure that the .git/config files are set up correctly for each project. You probably want your two apps .git/config files to look something like the following:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "heroku"]
    url = [email protected]:floating-dusk-xxxx.git
    fetch = +refs/heads/*:refs/remotes/heroku/*

And the other one like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "heroku"]
    url = [email protected]:boiling-bastion-xxxx.git
    fetch = +refs/heads/*:refs/remotes/heroku/*

It's okay if your config files look a little different, and have some extra sections in them, the key part is the url under the [remote "heroku"] section.

Then, you can push these two different apps to two different Heroku repositories (which then lets you navigate to these two apps at their seperate, respective blah-blah-xxxx.herokuapp.com URLs. In order to push an app to Heroku, make sure you've cd'd into the correct directory and then enter the command git push heroku master. This may not work right away in case the state you've left those Heroku remote repositories in is currently messed up, so please comment with any errors you run into.

Upvotes: 0

trymv
trymv

Reputation: 185

Err... I'm not sure if it's something I'm missing in your question, but this should be pretty straight-forward.

Create your new app

$ rails new yourapp
$ cd yourapp

Create a repository

$ git init
$ git add .
$ git commit -m "Initial commit"

Create, deploy and open the app @ Heroku

$ heroku create
$ git push heroku master
$ heroku open

EDIT: If what your looking for is a duplicated app on a new herokudomain, do as follows:

Duplicate you app folder locally and cd into the copy.

Delete the current remote (origin)

git remote rm origin

Add the new remote

git remote add origin <URL to second heroku app>

push to new domain

git push -u origin master

Upvotes: 1

Related Questions