> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cubic.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialize cubic

> Set up mg in your local repo to start using stacked PRs.

Learn how to configure **`mg`** so it knows your trunk branch and can manage stacked PRs.

<Info>
  **Why initialize?**

  `mg init` sets your trunk (often `main`), ensuring mg
  knows where to base new branches and how to restack them.
</Info>

***

## Steps

<Steps>
  <Step title="Navigate to Your Repo">
    ```bash theme={null}
    cd /path/to/your-project 
    ```
  </Step>

  <Step title="Run mg init">
    `bash mg init ` This will: - Prompt you to select `main` or `master` (or another trunk branch)

    * Create a `.git/cubic_repo_config` file for storing config
  </Step>

  <Step title="Confirm It Worked">
    ```bash theme={null}
    mg list 
    ```

    * If your repo already has branches, you'll see them listed
    * If it's a fresh repo, you'll see only `main`
  </Step>
</Steps>

<Note>
  **Authentication** If mg needs to push to GitHub and can't detect credentials, it may ask you to
  authenticate via `gh` or a personal access token.
</Note>

***

## Next steps

* Try the [Quickstart](/quickstart) for a hands-on example of creating and pushing stacked branches.
* Or see [Create a Pull Request](/how-to-guides/create-a-pull-request) for a single-branch workflow.

That's it! You've initialized **cubic** in your local repository.
