Skip to content

Commit cf49769

Browse files
authored
Merge pull request #45361 from github/repo-sync
Repo sync
2 parents 9196cbd + dab9f3e commit cf49769

108 files changed

Lines changed: 8175 additions & 82 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/content-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
# source-path, target-articles, etc.) is read from
3838
# src/content-pipelines/config.yml by the update script.
3939
- id: copilot-cli
40+
- id: gh-stack
4041
# - id: mcp-server
4142

4243
steps:

content/copilot/concepts/agents/copilot-cli/about-remote-control.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Remote control requires:
3232
* **The machine must be online**: The CLI session must be actively running in a terminal on a machine with an internet connection. If the machine goes to sleep or loses its connection, remote control is unavailable until the machine is back online. See [Reconnection](#reconnection) later in this article.
3333
* **An interactive session**: Remote access is only available for interactive sessions. It is not available when you use the CLI programmatically with the `--prompt` command-line option, for example when you use the CLI in a script.
3434

35+
Remote control does not require the working directory to contain a Git repository hosted on {% data variables.product.prodname_dotcom_the_website %}. For users whose {% data variables.product.prodname_copilot_short %} seat comes from an enterprise or organization, the applicable enterprise or organization policy, not repository hosting, determines whether remote control is available. See [Administering remote control](#administering-remote-control) later in this article.
36+
3537
## Accessing a session remotely
3638

3739
When you enable remote control for a {% data variables.copilot.copilot_cli_short %} session, you can go to {% data variables.product.prodname_dotcom_the_website %} or {% data variables.product.prodname_mobile %} and find the session in the list of your recent agent sessions. The remote interface is updated in real time, allowing you to monitor ongoing output from the session and respond to prompts and permission requests as they come in.
@@ -80,4 +82,6 @@ Enterprise and organization owners control whether users can enable remote contr
8082

8183
For remote control to be available, the applicable policy (enterprise-enforced or organization-level) must be set to "View and control."
8284

85+
Enterprise owners can further restrict remote control using the `remoteControl` enterprise managed setting, which applies on top of the "Store local sessions in the Cloud" policy. This setting is applied per device and controls whether a session **hosted on that device** can be remotely controlled: it can require that the controlling client is SSO-authorized for specific organizations, or disable remote control of sessions hosted on that device entirely. It doesn't affect the same user's ability to remotely control sessions hosted on other devices. See [AUTOTITLE](/copilot/reference/enterprise-managed-settings-reference).
86+
8387
For more information, see [AUTOTITLE](/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies) and [AUTOTITLE](/copilot/how-tos/copilot-cli/administer-copilot-cli-for-your-enterprise).

content/copilot/how-tos/copilot-cli/use-copilot-cli/steer-remotely.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ This article explains how to enable and use remote control. For more conceptual
2828
> [!TIP]
2929
> Use the `/keep-alive` slash command to prevent your machine from going to sleep while you're away. See [Preventing your machine from going to sleep](#preventing-your-machine-from-going-to-sleep).
3030
31-
* The working directory must contain a Git repository hosted on {% data variables.product.prodname_dotcom_the_website %}. If you are not in a {% data variables.product.prodname_dotcom %} repository, the CLI displays: "Remote session disabled: not in a {% data variables.product.github %} repository."
31+
* Remote control does not require a Git repository hosted on {% data variables.product.prodname_dotcom_the_website %}. You can enable remote control from directories that are not themselves Git repositories, including parent directories containing multiple repositories, and from repositories hosted somewhere other than {% data variables.product.prodname_dotcom_the_website %}. Sessions started outside of a {% data variables.product.prodname_dotcom %} repository appear unassociated with any repository ("no repository") and are only listed on your agents page at [github.com/copilot/agents](https://github.com/copilot/agents). Sessions started inside a {% data variables.product.prodname_dotcom %} repository also appear on that repository's **Agents** tab.
32+
33+
In some cases, the CLI may still be unable to resolve the working directory's repository—for example, if a Git remote is configured but inaccessible. When this happens, remote control is disabled and the CLI displays a "Remote session disabled" message.
3234

3335
## Enabling remote control for a session
3436

@@ -166,6 +168,8 @@ Remote control is disabled by default, but may be enabled in your {% data variab
166168
* **For a single session**: Start the CLI with `--no-remote` to prevent remote control for that session, regardless of your settings file value.
167169
* **Permanently**: Remove the `"remoteSessions": true` setting from `~/.copilot/settings.json`, or set it to `false`.
168170

171+
Enterprise owners can also restrict remote control of sessions hosted on your device using enterprise managed settings, regardless of your personal settings. Depending on the configured policy, remote control of sessions on your device may be disabled entirely, or only available to a controlling client that is SSO-authorized for specific organizations. This doesn't affect your ability to remotely control your own sessions hosted on other devices. See [AUTOTITLE](/copilot/reference/enterprise-managed-settings-reference).
172+
169173
## Further reading
170174

171175
* [{% data variables.copilot.copilot_cli_short %} sessions in {% data variables.product.prodname_vscode %}](https://code.visualstudio.com/docs/copilot/agents/copilot-cli) in the {% data variables.product.prodname_vscode_shortname %} documentation.

content/copilot/reference/enterprise-managed-settings-reference.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ When multiple settings sources are present, settings earlier in this list take p
3434
| `extraKnownMarketplaces` | Adds plugin marketplaces that users can access | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} |
3535
| `strictKnownMarketplaces` | Restricts plugin installation to explicitly listed marketplaces | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} |
3636
| `telemetry` | Configures OpenTelemetry export, routing {% data variables.product.prodname_copilot_short %} usage data to a collector of your choice | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
37+
| `remoteControl` | Restricts whether sessions hosted on this device can be remotely controlled, based on the controlling client's SSO authorization status for the listed organizations. Doesn't affect the user's ability to remotely control sessions hosted on other devices | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} | {% octicon "x" aria-label="Not supported" %} |
3738

3839
{% endrowheaders %}
3940

@@ -77,6 +78,10 @@ The following example shows these keys in one managed settings file.
7778
"headers": {
7879
"Authorization": "Bearer TOKEN"
7980
}
81+
},
82+
"remoteControl": {
83+
"mode": "requireSSO",
84+
"githubDotComOrganizations": ["ORG-NAME"]
8085
}
8186
}
8287
```
@@ -142,3 +147,10 @@ When you set the `telemetry` property, {% data variables.product.prodname_copilo
142147
* `serviceName`: A label for the telemetry service name (for example, `"copilot"`).
143148
* `resourceAttributes`: An object of OpenTelemetry resource attributes to attach to all exported telemetry (for example, `{"deployment.environment": "production"}`).
144149
* `headers`: An object of HTTP headers to include with each telemetry request (for example, an `Authorization` header for your collector).
150+
151+
## `remoteControl`
152+
153+
Restricts whether {% data variables.copilot.copilot_cli_short %} sessions hosted on a device can be remotely controlled. This doesn't affect a user's ability to remotely control their sessions hosted on other devices.
154+
155+
* `mode`: Set to `"disabled"` to prevent remote control of sessions on the device, `"requireSSO"` to only allow remote control from a client that is SSO-authorized for the organizations listed in `githubDotComOrganizations`, or `"enabled"` to allow it unrestricted.
156+
* `githubDotComOrganizations`: An array of organization logins. Required when `mode` is `"requireSSO"`.

content/copilot/tutorials/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ children:
2424
- /optimize-ai-usage
2525
- /optimize-code-reviews
2626
- /reduce-technical-debt
27+
- /stack-ai-generated-code-in-pull-requests
2728
- /review-ai-generated-code
2829
- /learn-a-new-language
2930
- /modernize-legacy-code
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
title: Stack AI-generated code in pull requests
3+
shortTitle: Stack AI pull requests
4+
intro: 'Create a stack of small, dependent pull requests that can be quickly reviewed.'
5+
versions:
6+
feature: copilot
7+
contentType: tutorials
8+
category:
9+
- Accelerate PR velocity
10+
- Team collaboration
11+
---
12+
13+
> [!NOTE]
14+
> Stacked pull requests are in {% data variables.release-phases.public_preview %} and subject to change.
15+
16+
Large pull requests are difficult to review and create bottlenecks, especially when AI helps you generate a high volume of code in a short time. Review quality also degrades as pull request size increases. Reviewers may skim the result, miss issues, or procrastinate and leave the pull request until it grows stale and develops merge conflicts.
17+
18+
Stacked pull requests keep large code changes reviewable.
19+
20+
{% data reusables.pull_requests.pr-stack-definition %}
21+
22+
This tutorial walks you through how to use stacked pull requests with agents to build a feature in individually reviewable layers. For our example, we'll consider how to add user authentication to an app. We'll use {% data variables.copilot.copilot_cli %} and the `gh-stack` agent skill.
23+
24+
## Prerequisites
25+
26+
To use the `gh-stack` skill with an agent, you'll first need to install {% data variables.product.prodname_cli %} and the `gh-stack` CLI extension. You'll need the following:
27+
28+
* {% data variables.product.prodname_cli %} (`gh`) 2.90.0 or later, and Git 2.20 or later.
29+
* Authenticate {% data variables.product.prodname_cli %} with `gh auth login`.
30+
* A {% data variables.product.github %} repository you can push to.
31+
* {% data variables.copilot.copilot_cli %} installed and signed in.
32+
33+
In {% data variables.product.prodname_cli %}, install the `gh-stack` extension and skill.
34+
35+
```shell
36+
gh extension install github/gh-stack
37+
gh skill install github/gh-stack
38+
```
39+
40+
> [!NOTE]
41+
> Throughout this tutorial, if you prefer to run stack commands yourself instead of letting {% data variables.product.prodname_copilot_short %} do it, you'll need to use {% data variables.product.prodname_cli %}.
42+
43+
## 1. Design a stack before you generate code
44+
45+
A good stack is like building a house, start with a strong foundation, frame the walls, install wiring, then finish the drywall. Each layer built, dependent on the one below. In the end, a reviewer should be able to read the pull requests from bottom to top and follow the feature coming together.
46+
47+
* Split the feature into layers. Each layer should be a single, coherent change that can be reviewed on its own.
48+
* Keep each layer small enough that its pull request is a quick read. If a layer feels like it needs a long description to review, it is probably too big.
49+
* Decide the boundaries yourself, or work with {% data variables.product.prodname_copilot_short %} on a plan. Either way, you own the shape of the stack.
50+
* Order the layers by dependency. Foundational changes go at the bottom. Anything that depends on them goes higher. For authentication, that might be:
51+
* Layer 1: data model and migration
52+
* Layer 2: CRUD endpoints
53+
* Layer 3: JWT middleware and guards
54+
* Layer 4: integration and unit tests
55+
56+
### Example prompts
57+
58+
* `Propose a layered approach to add user authentication to this app. Order the layers by dependency, keeping each layer independently reviewable.`
59+
* `Review my planned layers and flag any that are too large or that depend on a branch above them.`
60+
61+
## 2. Build the bottom layer first
62+
63+
Start the stack with the foundation. Everything above depends on getting this layer right.
64+
65+
* Inform {% data variables.product.prodname_copilot_short %} you'll be building a stacked pull request and ask it to build the first layer based on your plan. The agent uses the `gh-stack` skill to create the first branch of the stack.
66+
* If you prefer to create the stack yourself, create it directly with `gh stack init`, using a prefix to keep branch names tidy, for example, `gh stack init BRANCH-NAME-1`.
67+
* Review the generated change yourself before moving on. A mistake in the bottom layer propagates to every branch above it, so give it a review before moving on.
68+
69+
### Example prompts
70+
71+
* `Start the pr-stack and build only the first layer: the user data model and migration.`
72+
* `Conduct a review of the generated code and confirm this branch contains only the data model and migration, and nothing that belongs in a later layer.`
73+
74+
## 3. Stack each new code layer on top
75+
76+
With the foundation in place, build the rest of the feature one layer at a time.
77+
78+
* Ask {% data variables.product.prodname_copilot_short %} to add the next layer and implement it in the context of the layers below. The agent will add a branch to the top of the stack and commit the work there.
79+
* If you want to add a branch yourself, use `gh stack add BRANCH-NAME-NEXT`.
80+
* If a layer starts growing too large, consider whether it has drifted outside its plan or if you actually need two layers instead of one.
81+
* Create new branches for each layer as you go, so every branch stays a clean, self-contained diff.
82+
* When you're ready to create pull requests ask {% data variables.product.prodname_copilot_short %} to submit your stack, or if you want to do it yourself, use `gh stack submit`.
83+
* Let each pull request stand on its own. A focused title and a concise, meaningful description of the layer is usually enough.
84+
85+
### Example prompts
86+
87+
* `Add the next layer in a new branch on top: the CRUD endpoints that use the user model from the branch below.`
88+
* `This branch is getting large. Suggest how it could be split into two independently reviewable layers.`
89+
90+
## 4. Review the pull requests yourself before asking for a review
91+
92+
Each layer is small, making self-review easier too. Do a pass on every branch before you involve teammates. Reviewers should receive changes you already trust.
93+
94+
* Run your tests, linters, and code scanning on each branch. Let {% data variables.product.prodname_copilot_short %} help you check each layer against your standards before you request reviews.
95+
* For the techniques to review AI-generated changes thoroughly, see [AUTOTITLE](/copilot/tutorials/review-ai-generated-code).
96+
97+
## 5. Request reviews for the stack, starting at the bottom
98+
99+
With the layers built, reviewers get small diffs instead of a large wall of code.
100+
101+
* If the dependencies are strongly integrated, ask for reviews starting at the bottom of the stack, so you can integrate changes up the stack before subsequent reviews.
102+
* If you need reviews from separate folks for different layers, reviewers can work in parallel. One person can review the data model while another reviews the endpoints, and neither wades through the whole feature.
103+
104+
## 6. Iterate on feedback
105+
106+
Review feedback lands on layers individually, not the whole feature. Stacks let you fix the right layer in place and carry the change upward.
107+
108+
* Ask {% data variables.product.prodname_copilot_short %} to revise the layer a reviewer flagged. The agent moves to the right branch, makes the change, and commits it there. Then, it rebases the layers above so they pick up the fix.
109+
* Keep each fix in the layer it belongs to. A change made on the wrong branch can confuse and create errors upstack.
110+
* As you make fixes, ask {% data variables.product.prodname_copilot_short %} to rebase the branches above and propagate changes.
111+
* If you want to move through the stack yourself, navigate branches with `gh stack down`, `gh stack up`, or `gh stack checkout BRANCH-NAME`. Then, commit your changes and run `gh stack rebase --upstack` to carry changes up the stack.
112+
113+
### Example prompts
114+
115+
* `A reviewer flagged that the auth service doesn't handle expired tokens. Fix that on BRANCH-NAME and test the changes.`
116+
* `I've rebased the layers above onto this fix. Check that the branch with endpoints still works with the change and flag anything that needs updating.`
117+
118+
## 7. Merge from the bottom layer
119+
120+
A stack merges in order, starting from the layer pointing to your main branch. Merge layers all at once, or one-by-one, and GitHub automatically re-targets the next layer to point at main.
121+
122+
* Merge the stack one at a time working from the bottom up, or from anywhere in the stack and all the branches below the pull request you merge will be merged from the bottom up.
123+
* Each layer's diff stays exactly the same relative to its parent, only the base changes, making it easy to merge a layer at a time without affecting in-progress work or reviews.
124+
* Use auto-merge or a merge queue so each layer merges as soon as it is approved and its checks pass. You do not need to wait on the whole stack at once.
125+
126+
Once the top layer merges, the whole feature has landed. Every piece was reviewed more effectively as a small, deliberate change rather than one large pull request.
127+
128+
## Further reading
129+
130+
* [AUTOTITLE](/copilot/tutorials/review-ai-generated-code)
131+
* [AUTOTITLE](/pull-requests/how-tos/create-pull-requests/managing-stacked-pull-requests)

content/pull-requests/concepts/deploying-code.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ After a pull request is merged or closed, its head branch is often no longer nee
6262
## Further reading
6363

6464
* [AUTOTITLE](/pull-requests/how-tos/merge-and-close-pull-requests/merging-a-pull-request)
65+
{% ifversion pr-stacks %}* [AUTOTITLE](/pull-requests/how-tos/merge-and-close-pull-requests/merging-stacked-pull-requests){% endif %}
6566
* [AUTOTITLE](/pull-requests/reference/status-checks)
6667
* [AUTOTITLE](/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments)

content/pull-requests/concepts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ redirect_from:
66
- /github/collaborating-with-issues-and-pull-requests/overview
77
- /github/collaborating-with-pull-requests/getting-started
88
shortTitle: Concepts
9-
intro: 'Understand the foundational concepts of pull requests, including branches, forks, commits, reviews, and merges to streamline collaboration on {% data variables.product.github %}.'
9+
intro: 'Understand how pull requests help you write code and collaborate effectively on {% data variables.product.github %}.'
1010
versions:
1111
fpt: '*'
1212
ghes: '*'

content/pull-requests/get-started/about-pull-requests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Pull requests turn a set of code changes into a conversation. Instead of merging
2626
Pull requests make your changes easy to review and validate. With a pull request, you can:
2727

2828
* Propose changes from a branch or a fork.
29+
{% ifversion pr-stacks %}* {% data reusables.pull_requests.pr-stack-invitation %}{% endif %}
2930
* Discuss and review the proposed changes, line by line.
3031
* Run automated checks, such as tests, builds, and code scanning, against the changes.
3132
* Respond to feedback and update the pull request as it evolves.

0 commit comments

Comments
 (0)