# Concepts for StackedPRs CLI

## Branch and stack

We have two kinds of branches in Aviator CLI:

* Trunk branches: Branches that PRs are merged into. Typically, `main` or `master`.
* [<mark style="color:blue;">Topic branches</mark>](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows#_topic_branch): Branches that contain proposed changes against trunk branches.

  <figure><img src="/files/harhYA4OP7MWhy0pNRIF" alt=""><figcaption><p>main is the trunk branch, and feature1 and feature2 are topic branches</p></figcaption></figure>

A stack is a series of topic branches. Each branch has one parent branch, and the root of the stack has a trunk branch as a parent. One branch corresponds to one pull-request in GitHub. All pull-requests are ultimately merged into the trunk branch they are rooted. Aviator CLI internally tracks parent-child relationships of branches.

When a parent branch is needed, and it is not specified, it uses the remote `HEAD` as the default trunk branch. This is typically a branch that you set as the default branch on GitHub.

## Sync

<figure><img src="/files/hYEfPHfJn309zSWcodJa" alt=""><figcaption><p>After sync operation, the branches regain the parent-child relationship in their commits.</p></figcaption></figure>

As you add more code to the stack, the state of the stack can be out of sync. For example:

* The `main` branch on the remote gets updates by merging other pull-requests.
* A new commit is added or a commit is amended in one of the parent branches.
* Some of the parents are merged.

In those cases, you want to rebase your branches on top of the new commits. Sync is an action that does that for you. Aviator CLI uses the recorded branch parent to figure out which commit a branch should be rebased onto, and it pushes the new state to GitHub as needed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aviator.co/aviator-cli/concepts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
