---
title: "How the GitHub CLI can now enable triangular workflows"
description: "GitHub CLI v2.71.2 makes `gh pr` commands resolve a branch's push and pull targets the same way Git does, so triangular workflows work."
url: "https://swe.quest/articles/how-the-github-cli-can-now-enable-triangular-workflows-9d168cb0f33f735d"
canonical: "https://github.blog/open-source/git/how-the-github-cli-can-now-enable-triangular-workflows/"
source: "GitHub Engineering"
published: "2025-04-25"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 10
tags: ["version-control","developer-tools"]
---

# How the GitHub CLI can now enable triangular workflows

A post on [GitHub Engineering](https://swe.quest/sources/github.md), published 2025-04-25, 10 min read, Deep dive. Original: [https://github.blog/open-source/git/how-the-github-cli-can-now-enable-triangular-workflows/](https://github.blog/open-source/git/how-the-github-cli-can-now-enable-triangular-workflows/)

## Summary

GitHub CLI v2.71.2 makes \`gh pr\` commands resolve a branch's push and pull targets the same way Git does, so triangular workflows work. In a triangular workflow a branch pulls from one ref, such as upstream's default branch, and pushes to another, such as the same-named branch on a fork. The post shows how to set this up in \`.git/config\` with a branch's \`merge\` key, the per-branch \`pushremote\` key, or the repo-wide \`remote.pushDefault\`, and notes that \`pushremote\` overrides \`remote.pushDefault\`. To find a pull request's headRef, the CLI checks \`@{push}\` first, then \`pushremote\`, then \`remote.pushDefault\`, and it treats the branch's pullRef as the PR's baseRef, so if \`git push\` and \`git pull\` are configured correctly, \`gh pr\` should just work.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Version control](https://swe.quest/tags/version-control.md) (Engineering practices)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- Git branches and remotes
- Pull requests

## Keywords

GitHub CLI, Git, gh pr, @{push}, pushremote, remote.pushDefault

## Related posts

- [Enabling branch deployments through IssueOps with GitHub Actions](https://swe.quest/articles/enabling-branch-deployments-through-issueops-with-github-actions-8c407fc129221de6.md): GitHub Engineering · 2023-02-02 · Medium · 6 min read · Deployment, CI/CD, Infrastructure as code
  GitHub's branch-deploy Action brings the branch deploy model to any repository through IssueOps: comment commands like \`.deploy\` or \`.deploy noop\` on a pull request trigger a GitHub Actions workflow that deploys the branch before it is merged.
- [Scripting with GitHub CLI](https://swe.quest/articles/scripting-with-github-cli-91a3a551f29d6152.md): GitHub Engineering · 2021-03-11 · Medium · 6 min read · Developer tools, CI/CD, API design
  GitHub CLI (\`gh\`) can be extended and scripted by combining it with standard Unix tools.
- [Using Github Actions with Railway](https://swe.quest/articles/using-github-actions-with-railway-5eb8da35bcdd7f7c.md): Railway · 2021-06-04 · Medium · 2 min read · CI/CD, Deployment
  Railway deployments can be driven from GitHub Actions instead of the built-in branch-push trigger by creating a project token, storing it as a repository secret (RAILWAY\_TOKEN), and running \`railway up --service=\<id\>\` inside the official Railway CLI container.
- [Working with NX, Railway and CI/CD](https://swe.quest/articles/working-with-nx-railway-and-ci-cd-0bc2b769ee29696c.md): Railway · 2022-09-16 · Medium · 3 min read · CI/CD, Deployment, Build systems, JavaScript
  A GitHub Actions workflow can deploy only the NX monorepo apps affected by a push to Railway, replacing Railway's built-in GitHub trigger.
- [Building GitHub with Ruby and Rails](https://swe.quest/articles/building-github-with-ruby-and-rails-99851966c067c871.md): GitHub Engineering · 2023-04-06 · Medium · 5 min read · Ruby, Refactoring & migrations, CI/CD, Deployment, Open source
  GitHub's ~2M-line Rails monolith upgrades to the latest Rails main-branch commit every week via a scheduled GitHub Actions workflow that opens an automated PR, runs all builds, and ships the next day.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
