Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push current branch to a remote with Heroku

I'm trying to create a staging branch on Heroku, but there's something I don't quite get.

Assuming I've already created a heroku app and setup the remote to point to staging-remote, If I do:

git checkout -b staging staging-remote/master

I get a local branch called 'staging' which tracks staging-remote/master - or that's what I thought....

But:

git remote show staging-remote

Gives me this:

remote staging
  Fetch URL: [email protected]:myappname.git
  Push  URL: [email protected]:myappname.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    staging-remote merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

As you can see, the pull looks reasonable, but the default push does not. It implies that if I do:

git push staging-remote

I'm going to push my local master branch up to the staging branch. But that's not what I want.... Basically, I want to merge updates into my staging branch, then easily push it to heroku without having to specify the branch like so:

git push staging-remote mybranch:master

The above isn't hard to do, but I want to avoid accidentally doing the previous push and pushing the wrong branch... This is doubly important for the production branch I'd like to create!

I've tried messing with git config, but haven't figured out how to get this right yet...

like image 978
cmaughan Avatar asked Mar 08 '10 12:03

cmaughan


People also ask

How do I push current branch to Heroku?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.

Can you push to GitHub and Heroku?

You can now push your project to GitHub and it will be automatically deployed to Heroku henceforth.

What does git push Heroku master?

The magic, however, comes with the 'git push heroku master' command which starts the deployment pipeline processing that detects what programming language you are using and auto-magically downloads and bundles up all the necessary third party packages needed to launch, run, and manage your app.


1 Answers

I have tested it and @juba and @MatthewFord's versions work perfectly!

git config remote.staging.push staging:master

This pushes my local topic branch named staging into remote branch master on the remote repository named staging.

@nickgrim put it in the general form like so:

git config remote.[remoteRepositoryName].push [localBranchName]:[remoteBranchName]

Update:

Furthermore, modern git will conveniently run the above configuration command for you when you git push with the -u option:

git push -u staging staging:master
like image 101
thekingoftruth Avatar answered Oct 22 '22 15:10

thekingoftruth