Last active
October 5, 2025 12:05
-
Star
(147)
You must be signed in to star a gist -
Fork
(59)
You must be signed in to fork a gist
-
-
Save randallreedjr/aa89e069371d07371882eea2df15fb4d to your computer and use it in GitHub Desktop.
Revisions
-
randallreedjr revised this gist
Jun 5, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,7 +44,7 @@ $ git remote add heroku [email protected]:app.git ### List your git remotes The `-v` is the flag for "verbose" and includes the remote URL in addition to the remote name. ``` $ git remote -v -
randallreedjr revised this gist
Jun 5, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,9 @@ $ git remote add heroku [email protected]:app.git ## Other useful commands ### List your git remotes The -v if the flag for "verbose" and includes the remote URL in addition to the remote name. ``` $ git remote -v ``` -
randallreedjr revised this gist
Jun 5, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ In some cases, your local branch may be missing some commits that were already d $ git push staging staging:master -f ``` ### Add a remote for your Production app and deploy By convention, the remote name "heroku" is typically used for the production application. ``` $ git remote add heroku https://git.heroku.com/app.git -
randallreedjr revised this gist
Jan 17, 2020 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,11 @@ As [@voke](https://gist.github.com/randallreedjr/aa89e069371d07371882eea2df15fb4 $ heroku git:remote -a staging-app ``` **Edit:** Thanks to [@nruth](https://gist.github.com/randallreedjr/aa89e069371d07371882eea2df15fb4d#gistcomment-3141611) for pointing out you can supply a remote name to this command with the `-r` flag. ``` $ heroku git:remote -a staging-app -r staging ``` ### Add a remote using the SSH protocol As [@Saworieza](https://gist.github.com/randallreedjr/aa89e069371d07371882eea2df15fb4d#gistcomment-2784952) points out, all of the examples above use the https protocol for connecting to the remotes, but it is also possible to connect via ssh. ``` -
randallreedjr revised this gist
Nov 22, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,13 +23,13 @@ $ git push heroku master ``` ### Add a remote via Heroku CLI As [@voke](https://gist.github.com/randallreedjr/aa89e069371d07371882eea2df15fb4d#gistcomment-3079752) points out, you can alternatively use a [Heroku CLI command](https://devcenter.heroku.com/articles/git#creating-a-heroku-remote) to add your remote. However, it looks like this will always use the default remote name `heroku` for the remote. If you would like to use a different name for your remote, see the "Rename a remote" section below. ``` $ heroku git:remote -a staging-app ``` ### Add a remote using the SSH protocol As [@Saworieza](https://gist.github.com/randallreedjr/aa89e069371d07371882eea2df15fb4d#gistcomment-2784952) points out, all of the examples above use the https protocol for connecting to the remotes, but it is also possible to connect via ssh. ``` $ git remote add staging [email protected]:staging-app.git $ git remote add heroku [email protected]:app.git -
randallreedjr revised this gist
Nov 22, 2019 . 1 changed file with 39 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,37 +2,54 @@ Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. `heroku create`. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful. ## Adding a new remote ### Add a remote for your Staging app and deploy Note that on Heroku, you must always use `master` as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax `local_branch:destination_branch` seen below (in this example, we push the local `staging` branch to the `master` branch on heroku. ``` $ git remote add staging https://git.heroku.com/staging-app.git $ git push staging staging:master ``` In some cases, your local branch may be missing some commits that were already deployed to Heroku, resulting in an error. If you are **very sure** you want to proceed, add the `--force` (`-f`) flag. ``` $ git push staging staging:master -f ``` ### Add a remote for your Production app and deployu By convention, the remote name "heroku" is typically used for the production application. ``` $ git remote add heroku https://git.heroku.com/app.git $ git push heroku master ``` ### Add a remote via Heroku CLI As @voke points out, you can alternatively use a [Heroku CLI command](https://devcenter.heroku.com/articles/git#creating-a-heroku-remote) to add your remote. However, it looks like this will always use the default remote name `heroku`. If you would like to use a different name for your remote, see the "Rename a remote" section below. ``` $ heroku git:remote -a staging-app ``` ### Add a remote using the SSH protocol As @Saworieza points out, all of the examples above use the https protocol for connecting to the remotes, but it is also to connect via ssh. ``` $ git remote add staging [email protected]:staging-app.git $ git remote add heroku [email protected]:app.git ``` ## Other useful commands ### List your git remotes ``` $ git remote -v ``` ### Rename a remote ``` $ git remote rename heroku staging ``` ### Change a remote URL or protocol If you have already created https remotes and want to switch them to use ssh, the following command can be used. This command can also be used to change the target URL without changing the protocol ``` $ git remote set-url staging [email protected]:staging-app.git $ git remote set-url heroku https://git.heroku.com/production-app.git ``` -
randallreedjr renamed this gist
Nov 22, 2019 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ # Working with git remotes on Heroku Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. `heroku create`. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful. # Add a remote for your staging app and deploy; note that on Heroku, you must always use `master` as the # destination branch on the remote -
randallreedjr revised this gist
Nov 22, 2019 . 1 changed file with 20 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,16 @@ # Generally, you will add a git remote for your Heroku app during the Heroku app creation process, # i.e. `heroku create` # However, if you are working on an existing app and want to add git remotes to enable manual deploys, # the following commands may be useful # Add a remote for your staging app and deploy; note that on Heroku, you must always use `master` as the # destination branch on the remote # If you want to deploy a different branch, you can use the syntax below (in this example, we push the # local `staging` branch to the `master` branch on heroku $ git remote add staging https://git.heroku.com/staging-app.git $ git push staging staging:master # In some cases, your local branch may be missing some commits that were already deployed to Heroku, # resulting in an error. If you are sure you want to proceed, add the --force (-f) flag $ git push staging staging:master -f @@ -22,4 +27,13 @@ $ git remote -v # However, it looks like this will always use the default remote name "heroku" # You could then use git to rename the remote, as follows $ heroku git:remote -a staging-app $ git remote rename heroku staging # As @Saworieza points out, all of the examples above use the https protocol for connecting to the remotes, # but it is also to connect via ssh $ git remote add staging [email protected]:staging-app.git $ git remote add heroku [email protected]:app.git # If you have already created https remotes and want to switch them to use ssh, the following command can be used $ git remote set-url staging [email protected]:staging-app.git -
randallreedjr revised this gist
Nov 22, 2019 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,4 +11,15 @@ $ git push staging staging:master -f # By convention, the remote name "heroku" is typically used for the production application $ git remote add heroku https://git.heroku.com/app.git $ git push heroku master # To see a list of your remotes $ git remote -v # As @voke points out, you can alternatively use a Heroku CLI command. # https://devcenter.heroku.com/articles/git#creating-a-heroku-remote # However, it looks like this will always use the default remote name "heroku" # You could then use git to rename the remote, as follows $ heroku git:remote -a staging-app $ git remote rename heroku staging -
randallreedjr revised this gist
Nov 22, 2019 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,14 @@ # Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. `heroku create` # However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful # Add a remote for your staging app and deploy; note that on Heroku, you must always use `master` as the destination branch on the remote # If you want to deploy a different branch, you can use the syntax below (in this example, we push the local `staging` branch to the `master` branch on heroku $ git remote add staging https://git.heroku.com/staging-app.git $ git push staging staging:master # In some cases, your local branch may be missing some commits that were already deployed to Heroku, resultin in an error. If you are sure you want to proceed, add the --force (-f) flag $ git push staging staging:master -f # By convention, the remote name "heroku" is typically used for the production application $ git remote add heroku https://git.heroku.com/app.git $ git push heroku master -
randallreedjr created this gist
Dec 30, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ $ git remote add staging https://git.heroku.com/staging-app.git $ git remote add heroku https://git.heroku.com/app.git