1

There are answers about different remotes for push and pull, but is it possible to have different tracking branches for pull and push, from same remote, or even from different remotes?

In my workflow, it's often to pull from master branch of upstream, and then push to another personal branch of upstream, or some branch of another personal remote.

Kan Li
  • 8,557
  • 8
  • 53
  • 93

1 Answers1

1

pull from master branch of upstream, and then push to another personal branch of upstream, or some branch of another personal remote.

You've outgrown the factory default push.default of simple. current or Git's original matching will serve.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • I think [`branch..remote`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-branchltnamegtremote), `branch..pushRemote` and `branch..merge` provide more flexibility. – phd May 13 '19 at 19:21
  • @phd Not here. OP specifically wants different `.merge` and push target branch names. There's a config to merge from a different branch name by default, and to push back to that same branch name or your working branch name, but not to push to a _third_ branch name. For that, you have to name the target on the command line or with your own scripted workflow. Merge from anything into your own branch name and push to your own branch name in any remote, that's within Git's definition of ~ordinary enough to be configurable as s.o.p.~. – jthill May 13 '19 at 20:50
  • 1
    @phd, thanks. Didn't know this setting before. Suppose I pull from branch `B1` on remote `R1`, to my local branch `B0`, and then push to branch `B2` on remote `R2`. Am I correct by doing this: 1) name `B0`==`B2`; 2) set `push.default=simple`; 3) `git branch -u B1`; 4) set `branch.B0.remote=R1` and `branch.B0.pushRemote=R2`? Did I miss anything? – Kan Li May 14 '19 at 21:48
  • With these settings you pull from remote `R1` branch `B0` to `B0`, and push `B0` to remote `R2`. If this is what you want ­ok. You can also configure different default remotes for pulling and pushing of any branch using [`remote.pushDefault`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-remotepushDefault). – phd May 14 '19 at 23:26