Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Configure Git branch to push to different remote than it pulls from
As a loose follow-up to Why force designation of a remote main branch?, is there a Git-native way to configure a branch for GitHub's so-called "triangular" workflow?
The triangular workflow is meant for synchronizing upstream branches, namely abbreviating this:
git switch main
git pull upstream/main
git push origin/main
into this:
git switch main
git pull
git push
GitHub has invented a pushremote property on the [branch "foo"] configuration to set this, but it only works with their gh CLI tool.
Is there a way to suggest to Git (which can pull/push from different branches) to pull/push from different remotes?
1 answer
The following users marked this post as Works for me:
| User | Comment | Date |
|---|---|---|
| Michael | (no comment) | May 21, 2026 at 18:18 |
pushRemote is not exclusive to gh.
From man git-config (or the documentation website):
branch.<name>.pushRemoteWhen on branch
<name>, it overridesbranch.<name>.remotefor pushing. It also overridesremote.pushDefaultfor pushing from branch<name>. When you pull from one place (e.g. your upstream) and push to another place (e.g. your own publishing repository), you would want to setremote.pushDefaultto specify the remote to push to for all branches, and use this option to override it for a specific branch.

0 comment threads