Chowlett
Chowlett

Reputation: 46667

Always push to different branch on remote, without setting upstream

It strikes me that git can practically make coffee while playing a cello, so it must be powerful enough to do this.

I'm developing an app, with the code stored on github, and am in the process of migrating it from Heroku to OpenShift. As a result, origin is github and I have a branch named migrate_to_openshift. This branch's upstream is origin/migrate_to_openshift, and I don't want to change that - I want a simple git push to push to the same branch on github.

However, to deploy to OpenShift, I have to push to master on the openshift remote. At the moment, that means I need to git push openshift migrate_to_openshift:master, which is a bit long-winded. Can I configure git so that git push openshift will do that by default?

Upvotes: 3

Views: 60

Answers (1)

torek
torek

Reputation: 488163

According to the git-config documentation:

remote.<name>.push
     The default set of "refspec" for git-push(1). See git-push(1).

So, setting remote.openshift.push to migrate_to_openshift:master should do that, although it will make that happen every time you run git push openshift (with no additional arguments), regardless of which branch you're on.

(I generally find these things too overly tricky to bother with—I just make an alias for special cases, e.g., git config alias.po "push openshift migrate_to_openshift:master" and then git po to run that. Otherwise I start relying on the magic, which I can find but never remember easily, and then I try to do something like this on a coworker's setup and it explodes messily.)

Upvotes: 2

Related Questions