Heroku is an excellent app hosting service that supports several frameworks. Suppose you already have an app deployed on heroku with the following address:
your_app.herokuapp.com and now you want to continue developing your app on a different machine.
Scenario 1: You hosted your source code somewhere else, say, http://www.github.com. You already pull the source code from it by doing
git clone https://github.com/username/your_project_name.git. Now, for your changes how do you push app to heroku?
If you have never used heroku on this new machine, you need to install it:
[crayon-5ba89193e4cda156882556/] Next, cd to
your_app directory and login to heroku using your credentials:
[crayon-5ba89193e4ce6407665210/] It is interesting to note that you can refer your local project to more than one remote repositories. This makes possible for you to pull from a remote repository remote and push your changes to another. Moreover, in your local project, git stores a nickname or alias of each remote repository you are referring to.
Now, in order to link your local directory to your remote repository on heroku, in your project directory run the following command:
[crayon-5ba89193e4cea549251537/] Let’s take a look at what the above line does. The
git remote is a command used to manage remote repositories. Option
add will add heroku remote repository to your local directory. The
heroku is the alias, or nickname of that remote repository. Lastly, the
email@example.com:your_app.git is the address of the remote repository.
After adding the remote repository, try running
[crayon-5ba89193e4ced015941661/] This will show your remote aliases. In this case you will see
[crayon-5ba89193e4cf1990474397/] They are the nicknames of the two remote repositories that are linked to your local directory, the second one is where you first clone your code from, the first one is the one on heroku that you just add. To view details of those remote repositories, run
[crayon-5ba89193e4cf4684499840/] In order to push your change to heroku, simply run
heroku login, pull the source code:
[crayon-5ba89193e4cfa908874819/] Because there is now only one remote repository related to your local machine, you just need to do
git pushto apply your changes.
Conclusion: This short post shows you how to use heroku connect to existing app. The key thing here is the ability of git to refer local project to as many remote repositories as you want. More reading about
git remote can be found here: http://gitref.org/remotes/. Oh by the way, don’t you notice that
heroku also uses
git for version control ? Have fun !!!!