Chowlett
Chowlett

Reputation: 46667

Set target branch for non-tracking remote

I have a web-app deployed on heroku. In order to update the running instance, I must git push my code to the master branch of the heroku remote.

I also keep my code on github, and have github as my origin and upstream repository. I'm trying a slightly new workflow, and therefore my local-and-github master branch contains the latest stable version I'm working on locally; while a local-and-github release branch contains the code which is actually running on heroku.

Given all that, my workflow currently looks like this:

$ git checkout master
... make some changes ...
$ git commit
$ git push                # to origin/master - that is, github
$ git checkout release
$ git merge master
$ git push heroku master  # Push the release branch to heroku's master branch, thereby sending it live.

I would like to avoid having to type master after the git push heroku line each time. I will never want to push to anything other than master on heroku. Is it possible to change my git config so that pushes to heroku of the local release branch update the master branch on heroku?

Upvotes: 0

Views: 298

Answers (2)

Jordan McCullough
Jordan McCullough

Reputation: 2785

Adding a custom refspec to the configuation and denoting the topic branch release being assigned to the destination's remote branch of master will perform the desired git push heroku action.

git config --add remote.heroku.push refs/heads/release:refs/heads/master

In other words, the refspec is saying for any push to this remote:

  1. The source branch (local) is the release branch
  2. The destination branch (remote) is master branch
  3. Always transmit release commits to master on this remote

More about customizing refspecs is available here.

Upvotes: 1

zanerock
zanerock

Reputation: 3552

git 1.8:

git branch --set-upstream-to=heroku/master release

git 1.7:

git branch --set-upstream release heroku/master

Upvotes: 0

Related Questions