# Stash Latest : Using pull requests in Stash

This page last changed on Oct 08, 2012 by pwatson.

Pull requests in Stash provide the team with a quick and easy way to review changes made on a branch, discuss those changes, and make further modifications before the branch is merged back to master or your main development branch. | On this page: Creating a pull request Discussing a pull request Merging a pull request Watching and notifications Related pages: Managing permissions for a project

## Creating a pull request

When you are ready to start a discussion about your code changes, simply create a pull request.

To create a pull request:

1. Go to the repository in Stash.
2. Click Pull request at the top of the page.
3. Choose the source and destination branches. The source branch is where you made your changes and the destination is the branch you want to merge to.

4. Pick a title and description to help people understand what your pull request is about.
5. Add reviewers – they will receive a notification by email. Other people who have permissions on the project can participate in the discussion if it interests them.
6. Click Create Pull Request.

After creating the pull request, you can modify it later by clicking Edit on the pull request page.

You will receive email notifications when your reviewers and other participants comment on the pull request, or commit changes to it.

## Discussing a pull request

The most important thing about a pull request is the discussion that it generates. To help you contribute to the discussion, Stash organises all the information about the pull request into 3 tabs.

#### Overview

The Overview tab captures all of the team's activity on the pull request in one place, right from the initial creation, through to when it is finally merged (or declined), with all the comments, replies and commits that happen along the way.

You can add a comment on the Overview tab (above the activity), or reply to a previous comment.

#### Diff

Diffs for Stash pull requests provide the following advantages:

- The diff highlights the changes that will result when the merge occurs, so you can see exactly what the effect of the merge will be.
- The diff tree on the left colour-codes files that have been added, changed or deleted, so you can quickly see the files you may need to review.
- As you'd expect, the diff for a file shows which lines of code have been added, deleted or modified.
- You can comment directly on a line of code right in the diff, by hovering over the line, clicking the icon and entering your comment. Your comment will also appear in the activity.
- Comments in the diff are threaded, to allow meaningful and contextual conversations about your code.

#### Commits

The Commits tab lists all the commits that will get merged.

Participants can commit new changes to the branch. Stash auto-updates the Commits tab of the pull request, so you can see exactly which commits will be merged. Stash is smart about comments, moving them along when lines are added or removed. If a line with a comment gets removed, you can still view the comment in the activity, but Stash marks the diff as outdated to let you know that this piece of code has been changed in recent commits.

## Merging a pull request

Once you are ready to merge a pull request, and when the reviewers have approved it, simply click Merge at the top right of the pull request view. You can only merge a pull request if you have Contributor permission on the project.

Once accepted, the pull request is marked as merged on the Pull Requests tab.

## Watching and notifications

You automatically get added as a watcher of a pull request when you perform an action related to the pull request, such as adding a comment. You can manually add yourself as a watcher by clicking the Watch button on the pull request screen.

You can always stop watching a pull request by clicking the link in the email notification, or the Unwatch button on the pull request screen. If you stop watching a pull request you will not automatically be added as a watcher again if you subsequently perform an action that would otherwise have added you.

Stash sends email notifications to watchers when certain events occur. See Notifications for details.

Action | You are added as a watcher
--- | ---
You are added as a reviewer |
You comment on a pull request |
You reply to a comment |
You push to the source branch |
You approve the pull request |

## Attachments:

STASH13_pull_request_sourcebranch.png (image/png)
STASH13_pull_requests_open.png (image/png)
STASH13_pull_request_accept.png (image/png)
STASH13_pull_requests_open.png (image/png)
STASH13_start_pull_request.png (image/png)
STASH13_start_pull_request.png (image/png)
STASH13_diff_comment.png (image/png)
Pull Request.png (image/png)
STASH13_merge.png (image/png)