There are two concepts at play when adding a user friendly heroku name to a git repos.

There is the remote (git) and the app (heroku).

git remote

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 git@heroku.com:.git (fetch)
heroku git@heroku.com:.git (push)
origin git@github.com:/.git (fetch)
origin git@github.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.

heroku apps

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
fathomless-dusk-xxx
secret-waters-xxxx

And you can get more info (like it’s git url) by typing:

> heroku info -a secret-waters-xxxx

=== secret-waters-7537
Addons: heroku-postgresql:dev
Git URL: git@heroku.com:secret-waters-xxxx.git
Owner Email: user@example.com
Region: us
Repo Size: 7M
Slug Size: 33M
Stack: cedar
Tier: Legacy
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 git@heroku.com:secret-waters-xxxx.git

Now when I list my apps I should see staging there:

> git remote -v


staging git@heroku.com:secret-waters-xxxx.git (fetch)
staging git@heroku.com: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:

Heroku