---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-work.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/pr-work.md
  - href: en/sourcecraft/operations/pr-work.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: How to work with pull requests in SourceCraft
description: Follow this guide to learn how to perform standard actions when working with pull requests in SourceCraft.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


# Working with pull requests in SourceCraft

<!-- source: en/_includes/sourcecraft/pr-work-in-ui.md -->
To work with pull requests in SourceCraft, including for approvals, you do not need to switch to an IDE on your local computer: you can do all the steps in the SourceCraft interface. You can [navigate and search through the project code](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md) and [edit the code](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-edit.md).
<!-- endsource: en/_includes/sourcecraft/pr-work-in-ui.md -->

Once a pull request is [created and published](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-create.md), you can:

* [Create a new iteration](#create-iteration).
* [View changes made to the target branch](#get-changes).
* [Leave a comment and request changes](#leave-comment).
* [Suggest your code and accept a suggestion](#code-suggestion).
* [Pass a resolution](#set-resolution).
* [Updating the source branch](#update-source-branch)
* [Merge with the target branch](#merge).
* [Rejecting a pull request](#discard).
* [Describing a pull request](#description).
* [Add labels](#add-labels).


## Creating a new iteration {#create-iteration}

Once a pull request is created, each push of changes to a remote repository branch creates a new _iteration_. This iteration includes all commits made before the `git push` command was executed.

To create a new iteration:
1. In the same branch the pull request was created from, make new changes to the repository files.
1. Add the modified files to the `git` index, commit, and push the changes to the remote repository:

    ```bash
    git add .
    git commit -m "<comment_to_commit>"
    git push origin <branch_name>
    ```

    Your iterations will register all previous changes, even if new commits were sent using the `git push --force` command.

    {% note info %}

    You can perform multiple commits and then push the changes to the remote repository. All of them will be included into one iteration.

    {% endnote %}

1. After you create a new iteration, the pull request gets the draft status. [Publish](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-create.md#create-from-draft) it again.

You can [make](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-edit.md) changes to the branch and create a new iteration directly in the SourceCraft interface.

## Viewing changes made to the target branch {#get-changes}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. View the contents of the pull request:
    * The ![image](../../_assets/console-icons/circle-exclamation.svg) **Overview** tab displays the history of its iterations. To view the changes from a specific iteration, click ![image](../../_assets/console-icons/eye.svg) **Show changes** next to that iteration.
    * The ![image](../../_assets/console-icons/file-code.svg) **Files changed** tab displays the modified files in the repository.
      * To compare changes between iterations, select them from the drop-down lists in the **Compare** field.
      * To display the file structure, click ![image](../../_assets/console-icons/layout-side-content-left.svg) next to the drop-down lists for branch and iteration comparison.

        For more information, see [Navigating and searching by code in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md).

    * The ![image](../../_assets/console-icons/code-commit-horizontal.svg) **Commits** tab displays all commits for all the pull request's iterations.

## Leaving a comment and requesting changes {#leave-comment}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. Leave a comment:

    {% list tabs %}

    - General

      Enter your comment in the **Activity** section on the ![image](../../_assets/console-icons/circle-exclamation.svg) **Overview** tab.

    - On a specific row

      1. On the ![image](../../_assets/console-icons/file-code.svg) **Files changed** tab, click ![image](../../_assets/console-icons/comment.svg) next to the row you want to comment on.

          <!-- source: en/_includes/sourcecraft/multi-line-comment.md -->
          {% note tip %}

          You can comment or suggest changes for an entire block of code in one go. Do it by holding down the mouse pointer to the left of the row number you want to start with and releasing it opposite the row you want to end with.
              
          You can leave comments and code suggestions for any rows of the modified file. You are not limited to just the modified area.

          {% endnote %}
          <!-- endsource: en/_includes/sourcecraft/multi-line-comment.md -->

      1. In the window that opens, enter your comment.

    {% endlist %}

    <!-- source: en/_includes/sourcecraft/issue-pr-comment-parsing.md -->
    Descriptions and comments to [issues](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#issues) and [pull requests](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr) support short links to other issues and pull requests. Such entries automatically convert into hyperlinks that display a summary preview card on hover. Use the following formats:
    * `!<pull_request_number>`: Pull request in the current repository.
    * `<repository_slug>!<pull_request_number>`: Pull request in a different repository of the current organization.
    * `<organization_slug>/<repository_slug>!<pull_request_number>`: Pull request in the specified organization and repository.
    * `#<issue_number>`: Issue in the current repository.
    * `<repository_slug>#<issue_number>`: Issue in the a different repository of the current organization.
    * `<organization_slug>/<repository_slug>#<issue_number>`: Issue in the specified organization and repository.
    <!-- endsource: en/_includes/sourcecraft/issue-pr-comment-parsing.md -->

1. Optionally, select **Change request** to request the pull request's edits.
1. Click **Comment**.

    You can also save your comment as a draft to modify it later instead of publishing it right away. To do this, click **Draft**.

<!-- source: en/_includes/sourcecraft/create-issue-from-comment.md -->
{% note tip %}

You can create a new issue from a comment to a [pull request](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr) or [issue](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#issues) by clicking ![image](../../_assets/console-icons/ellipsis.svg) next to the comment and selecting ![image](../../_assets/console-icons/arrow-up-right-from-square.svg) **Create issue**.

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/create-issue-from-comment.md -->

## Suggesting code and accepting a suggestion {#code-suggestion}

### Suggesting code in a comment {#create-suggestion}

You can suggest a code snippet the pull request author can apply directly from the comment:
1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. In the ![image](../../_assets/console-icons/file-code.svg) **Files changed** tab, click ![image](../../_assets/console-icons/comment.svg) next to the line you want to suggest your code for.

    <!-- source: en/_includes/sourcecraft/multi-line-comment.md -->
    {% note tip %}

    You can comment or suggest changes for an entire block of code in one go. Do it by holding down the mouse pointer to the left of the row number you want to start with and releasing it opposite the row you want to end with.
        
    You can leave comments and code suggestions for any rows of the modified file. You are not limited to just the modified area.

    {% endnote %}
    <!-- endsource: en/_includes/sourcecraft/multi-line-comment.md -->

1. In the window that opens, click ![image](../../_assets/sourcecraft/file-plus-minus.svg) **Code suggestion**.
1. Enter the code you want to suggest.

    {% note warning %}

    A code suggestion differs from a regular comment by having the `suggestion` markup:

    ````markdown
    ```suggestion
    Suggested modifications
    ```
    ````

    Do not delete or modify this markup.

    {% endnote %}

1. Optionally, select **Change request** to request the pull request's edits.
1. Click **Comment**.

    You can also save your code suggestion as a draft to work on it later instead of publishing it right away. To do this, click **Draft**.

### Accepting code suggested in a comment {#apply-suggestion}

To accept a code suggestion from a single comment:
1. In the top-right corner of the comment showing the suggested code, click ![image](../../_assets/console-icons/check.svg).
1. Enter a commit message and click **Apply**.

To accept code suggestions from multiple comments with a single commit:
1. In the top-right corner of all comments you want to accept, click ![image](../../_assets/console-icons/plus.svg).
1. Depending on which tab you are on, apply the changes as follows:

    {% list tabs %}

    - Overview

      At the top of the page, in the section with the list of files you want to edit, click **Apply suggestions**.

    - Edited files

      At the bottom of the page, click **Apply**.

    {% endlist %}

1. Enter a commit message and click **Apply**.

To reject a suggestion, click ![image](../../_assets/console-icons/xmark.svg) in the top-right corner of the comment showing the suggested code.

## Passing a resolution {#set-resolution}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. In the top-right corner, click ![image](../../_assets/console-icons/chevron-down.svg) next to ![image](../../_assets/console-icons/thumbs-up.svg) **Approve**.
1. Select a resolution:
    * ![image](../../_assets/console-icons/thumbs-up.svg) **Approve**: Approve the current pull request iteration. Once you edit the pull request, you will need to get the resolution once again.
    * ![image](../../_assets/console-icons/thumbs-up-2.svg) **Trust**: Approve the current and all subsequent pull request iterations.
    * ![image](../../_assets/console-icons/ban.svg) **Block merge**: Prohibit merging edits from the pull request into the target branch.

## Updating the source branch {#update-source-branch}

If new commits are added to the target branch after the pull request is created, you can merge them into the source branch directly from the SourceCraft interface. This is useful when you need to check compatibility of the source branch changes with the latest state of the target branch, or resolve conflicts before a merge.

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. In the top-right corner, click ![image](../../_assets/console-icons/ellipsis.svg) and select **Update branch**.
1. Select an update method:

    * **Update with merge commit**: Creates a dedicated merge commit in the source branch to store the revision history of both branches.
    * **Update with squash and rebase**: Applies the source branch commits on top of the the latest commit in the target branch, maintaining a linear revision history.

1. In the confirmation window that opens, click **Yes, I’m sure**.

    If changes in the source and target branches overlap, the [conflict resolution](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/resolve-merge-conflicts.md#resolve) window will open. Once the conflicts are resolved and the changes are committed, the source branch will be updated.

## Merging with the target branch {#merge}

Once the pull request is approved, you can perform a merge with the target branch.

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. In the top-right corner, click ![image](../../_assets/console-icons/chevron-down.svg) next to ![image](../../_assets/console-icons/code-pull-request.svg) **Merge**.
1. Select the method of merging with the target branch:
    * **Create a merge commit**: Separate merge commit is created in the target branch, which saves the revision history of both branches. This gives you a clear idea of when and how the merge had taken place, while keeping the full development history unchanged.
    * **Squash and merge**: Before merging with the target branch, commits from the branch with changes are combined into a single commit. This helps maintain a cleaner and simpler revision history by reducing a series of small commits to a single one.
    * **Rebase and merge**: Commits from the branch with changes are joined to the main branch without creating a special merge commit. This moves commits from the branch with changes to the end of the target branch, preserving a linear revision history.
1. In the top-right corner, click ![image](../../_assets/console-icons/thumbs-up.svg) with the merge method you selected.

{% note tip %}

To automatically delete the source branch of a pull request after its merge with the target branch, enable the **Delete source branch when merged** option under **Merge settings**. This option overrides the default behavior specified for the repository in the [`.sourcecraft/branches.yaml`](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/branch-policies.md#branch-cleanup) file.

{% endnote %}

{% note info %}

You can also perform a [forced merge with a target branch](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-force-changes.md), skipping both PR review and any automatic checks.

{% endnote %}

## Rejecting a pull request {#discard}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. In the top-right corner, click ![image](../../_assets/console-icons/ellipsis.svg) and select **Discard pull request**.

## Describing a pull request {#description}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. Add or update the description under **Description**.

    You can [use](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/generate-description.md#generate-in-created) Code Assistant to generate a description; to do this, click ![image](../../_assets/console-icons/sparkles-fill.svg)</svg> **Generate with AI**.

    <!-- source: en/_includes/sourcecraft/ai-gen-desc-time.md -->
    Description generation may take a while.
    <!-- endsource: en/_includes/sourcecraft/ai-gen-desc-time.md -->

    <!-- source: en/_includes/sourcecraft/agents-md-tip.md -->
    {% note tip %}

    You can [set](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/generate-description.md#rules) the rules Code Assistant will follow to generate descriptions in the `AGENTS.md` file at the repository root.

    {% endnote %}
    <!-- endsource: en/_includes/sourcecraft/agents-md-tip.md -->

## Adding labels {#add-labels}

<iframe width="640" height="360" src="https://runtime.strm.yandex.ru/player/video/vplvy3j76gvqu4hornlt?autoplay=0&mute=0" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" frameborder="0" scrolling="no"></iframe>

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests**.
1. Select a pull request.
1. In the right-hand panel, under **Labels**, add [labels](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#labels).

#### Useful links {#see-also}

* [All guides on pull requests in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/index.md#pr)
* [SourceCraft resource relationships](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md)
