How the GitHub CLI can now enable triangular workflows

The GitHub CLI now supports common Git configurations for triangular workflows. Learn more about triangular workflows, how they work, and how to configure them for your Git workflows. Then, see how you can leverage these using the GitHub CLI.

Tyler McGoffin
12 min readintermediate
--
View Original

Overview

The article discusses the recent enhancements to the GitHub CLI that enable support for triangular workflows, allowing developers to pull changes from different branches directly into their feature branches. It explains the differences between centralized and triangular workflows, provides insights into Git fundamentals, and details how to configure Git for triangular workflows.

What You'll Learn

1

How to set up triangular workflows in Git using the GitHub CLI

2

Why triangular workflows can improve your Git workflow efficiency

3

How to configure Git to support different remotes for triangular workflows

Prerequisites & Requirements

  • Basic understanding of Git concepts and workflows
  • Familiarity with GitHub CLI(optional)

Key Questions Answered

What are triangular workflows and how do they differ from centralized workflows?
Triangular workflows involve pushing to and pulling from different refs, allowing developers to pull changes from a remote repository's default branch directly into their feature branch. This contrasts with centralized workflows, where branches push and pull from the same remote ref.
How can I configure Git for triangular workflows?
To configure Git for triangular workflows, you can set the branch's merge key to a different branch name in your .git/config file. This allows you to pull from one branch while pushing to another, facilitating a more flexible workflow.
What changes were made to the gh pr command set to support triangular workflows?
The gh pr command set was updated to resolve pushRefs and pullRefs in accordance with Git configurations. This means that when you set up triangular workflows, the CLI will respect your Git configuration, making pull requests easier to manage.
When should I use triangular workflows in my projects?
Triangular workflows are particularly useful when working with forks or when you need to keep your feature branch updated with changes from the main repository's default branch without constant merging or rebasing.

Technologies & Tools

Tool
Github CLI
Used to manage Git workflows and pull requests more efficiently.
Version Control
Git
The underlying version control system that supports both centralized and triangular workflows.

Key Actionable Insights

1
Implement triangular workflows to streamline your development process.
By allowing direct pulls from the main branch into your feature branch, you can reduce the need for frequent merges and rebases, making your workflow more efficient.
2
Utilize the @{push} revision syntax to easily reference your pushRef.
This built-in Git feature simplifies identifying the pushRef for a branch, enhancing your ability to manage and track changes effectively.
3
Configure your Git remotes thoughtfully when working with forks.
Using distinct names for your fork and source remotes can help maintain clarity in your workflow, especially when pushing and pulling changes across different repositories.

Common Pitfalls

1
Failing to properly configure remotes can lead to confusion in push and pull operations.
If remotes are not clearly defined, developers may inadvertently push changes to the wrong repository or branch, complicating collaboration and version control.

Related Concepts

Git Workflows
Pull Requests
Branch Management
Version Control Best Practices