There are two concepts at play here when add a user friend name hooking git up to a heroku app.
There is the remote (git) and the app (heroku).
Git remotes are just aliases for git repositories. You can see what alias are currently setup for your git repos by typing:
> git remote -v
heroku firstname.lastname@example.org:.git (fetch)
heroku email@example.com:.git (push)
origin firstname.lastname@example.org:/.git (fetch)
origin email@example.com:/.git (push)
origin and heroku are the remotes – and their corresponding git repos.
origin is my git hub repos.
heroku is my remote name for my heroku git repos.
When I type:
> git push heroku
It pushes my code to the heroku git repos using the ‘heroku’ git remote name.
When you create an instance of your code base on Heroku, it gives your app a name. You can see your app names by typing:
> heroku apps
=== My Apps
And you can get more info (like it’s git url) by typing:
> heroku info -a secret-waters-xxxx
Git URL: firstname.lastname@example.org:secret-waters-xxxx.git
Owner Email: email@example.com
Repo Size: 7M
Slug Size: 33M
Web URL: http://secret-waters-xxxx.herokuapp.com/
What we want to do is tie these things together.
Tying a remote to an app
Say I created a staging environment, and I want to replace the heroku generated name it gave me (like secret-water) with a nicer name like ‘staging’. Here is how I would do it.
git remote add staging firstname.lastname@example.org:secret-waters-xxxx.git
Now when I list my apps I should see staging there:
> git remote -v
staging email@example.com:secret-waters-xxxx.git (fetch)
staging firstname.lastname@example.org:secret-waters-xxxx.git (push)
And I should be able to push to my staging environment with this:
> git push staging
If you make a mistake you can remove a remote with
> git remote rm staging
For more examples of these and other commands feel free to checkout my heroku cheat sheet: