How to change a Git remote on Heroku

后端 未结 7 1496
慢半拍i
慢半拍i 2020-12-22 15:10

I do not want to upload my app to the wrong domain.

How can I change the git master branch on git?

相关标签:
7条回答
  • 2020-12-22 15:39
    1. View Remote URLs

      > git remote -v

        heroku  https://git.heroku.com/###########.git (fetch) < your Heroku Remote URL
        heroku  https://git.heroku.com/############.git (push)
        origin  https://github.com/#######/#####.git (fetch) < if you use GitHub then this is your GitHub remote URL
        origin  https://github.com/#######/#####.git (push)
    
    1. Remove Heroku remote URL

      > git remote rm heroku

    2. Set new Heroku URL

      > heroku git:remote -a ############

    And you are done.

    0 讨论(0)
  • 2020-12-22 15:40

    This worked for me:

    git remote set-url heroku <repo git>
    

    This replacement old url heroku.

    You can check with:

    git remote -v
    
    0 讨论(0)
  • 2020-12-22 15:40

    You can have as many branches you want, just as a regular git repository, but according to heroku docs, any branch other than master will be ignored.

    http://devcenter.heroku.com/articles/git

    Branches pushed to Heroku other than master will be ignored. If you’re working out of another branch locally, you can either merge to master before pushing, or specify that you want to push your local branch to a remote master.

    This means that you can push anything you want, but you app at heroku will always point to the master branch.

    But, if you question regards how to create branches and to work with git you should check this other question

    0 讨论(0)
  • 2020-12-22 15:41

    here is a better answer found through Git docs.

    This shows what the heroku remote is:

    $ git remote get-url heroku

    Found it here: https://git-scm.com/docs/git-remote Also in that document is a set-url, if you need to change it.

    0 讨论(0)
  • 2020-12-22 15:42

    Assuming your current remote is named origin then:

    Delete the current remote reference with

    git remote rm origin
    

    Add the new remote

    git remote add origin <URL to new heroku app>
    

    push to new domain

    git push -u origin master
    

    The -u will set this up as tracked.

    0 讨论(0)
  • 2020-12-22 15:46

    If you're working on the heroku remote (default):

    heroku git:remote -a [app name]
    

    If you want to specify a different remote, use the -r argument:

    heroku git:remote -a [app name] -r [remote] 
    

    EDIT: thanks to Алексей Володько For pointing it out that there's no need to delete the old remote.

    0 讨论(0)
提交回复
热议问题