Drive Git development from a work item in Azure Boards

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

One of the ways your team can drive their development and stay in sync is to link your work items to the objects created during development, such as branches, commits, pull requests, and builds. You can begin that linking by creating a branch from one or more work items. Later, you can create pull requests, quickly open commits, and maintain a record of development operations performed to complete specific work.

In this article, learn how to do the following tasks:

  • How to create a new branch or pull request from a work item
  • Complete the pull request
  • Perform a squash merge
  • Create a branch for several work items
  • Link a work item to existing development and build objects

This article addresses creating new branches, adding links to commits, and adding pull requests to a Git repository hosted on Azure DevOps. To link to GitHub commits and pull requests, see Link GitHub commits and pull requests to work items.

Tip

You can set up automatic linking and other settings that link work items to Git commits, pull requests, builds, and more. For more information, see the following resources:

Development control

The Development control records all Git development processes that support completion of the work item. This control can show your team information needed to take the next development step and minimize navigational steps to accomplish common development tasks. It also supports traceability, providing visibility into all the branches, commits, pull requests, and builds related to the work item.

Screenshot of work item form, Development control.

Screenshot of work item form, Development control, Azure DevOps Server 2019.

From it, you can quickly access branches, pull requests, and commits that are linked to the work item. Also, you can start a pull request for a branch you created or linked to from the work item.

Keep in mind that the Development control only appears within the web portal work item form. The work item tracking experience and forms that appear in Visual Studio or other supported clients don't display several of the features that are available from the web portal.

Prerequisites

  • Connect to a project. If you don't have a project yet, create one.
  • You must be added to a project as a member of the Contributors or Project Administrators security group. To get added, Add users to a project or team.
  • To view or modify work items, you must have your View work items in this node and Edit work items in this node permissions set to Allow. By default, the Contributors group has this permission set. For more information, see Set permissions and access for work tracking.
  • Connect to a project. If you don't have a project yet, create one.
  • You must be added to a project as a member of the Contributors or Project Administrators security group. To get added, Add users to a project or team.
  • To view or modify work items, you must have your View work items in this node and Edit work items in this node permissions set to Allow. By default, the Contributors group has this permission set. For more information, see Set permissions and access for work tracking.

Workflow process

Consider creating a new branch when there are no linked code artifacts. If a branch exists, but no pull requests, consider creating a pull request. Here's a typical workflow sequence when working with a Git repository.

  1. Start work on the work item by creating a branch. You can add a new Git branch from within the Development section...

    Screenshot of Development control, Create branch link.

    ... or, from the form's Actions menu.

    User story work item form, Action menu, add new branch.

    Name the branch and select the repository.

    Create a branch dialog box

    When you create branches, they automatically get linked to the work item.

    Note

    You can only create a branch once you've added files to the main branch, which we recommend you label main or other distinctive label. The system automatically adds a README file to the initial repo created with each new project.

  2. The system opens to the repository and branch that you created.

    You can edit a file within the web portal.

    Or, if you have extensive file edits or need to add files, work from Visual Studio or other supported IDE. Add a new local branch from the branch you created. For more information, see Update code with fetch and pull, Download changes with fetch. (While any code editing and committing process works, we work best with an edition of Visual Studio.)

  3. Add or modify files in the branch that you created.

    From Visual Studio or other supported IDE, commit and push changes from your local branch to the repository.

    Commit and push changes

    If it's your first time pushing changes from a new branch, publish the branch before you push changes. For more information, see Share code with push.

  4. Create a pull request from the work item form.

    You create a pull request to merge the changes you made to a main branch and get your changes reviewed by other members of your team.

    Screenshot of Development control, Create pull request link.

  5. Your view switches to Code, Pull Requests page. Complete creating the pull request as shown.

    Code view, Pull Request page.

    Note

    Once you've created a pull request, you can't create a new pull request for the same branch until you complete the previous pull request.

    Pull Request page, Create pull request.

    Check the box for Squash changes when merging and then complete the merge.

    Complete pull request dialog box, check squash-merge

  6. Upon completion, you should see a similar screen as follows.

    Pull request, completed notification

  7. Open the work item form or refresh the form, expand the Development section (choose Maximize Development ), and you see the links that were added to support the operations you completed.

    Screenshot of Work item form, Development section, links added.

Create a branch for several work items

You can also add a new branch from the work item listed on the backlog or Kanban board without having to open the work item. Using multi-select, you can select several work items and create a new branch where they're all linked to the branch.

For example, here we select the first five items to link to a new branch.

Screenshot of select multiple items from backlog, Create branch link.

And, we specify the name of the branch.

Create new branch dialog

All items listed under the Development section also appear under the Links tab. All development actions started from the Development section are also recorded under the History tab.

Links tab, development links

To link a work item to an existing object, choose the Add link Add links icon and then choose the link type.

Select Add links icon and then choose the link type.

If you want to remove a link, you can do so from the Development section by highlighting it first and then choose Remove link .

Development section, delete a link

Or, you can select it from the Links tab and choose Actions for the link and then choose the Remove link option.

Associated work items in build

With Git commits, any work items that were linked to a commit are listed under the Associated work items in the build summary page.

Linked work items listed under Associated work items in the build summary page.

Links shown in this section appear because of these actions:

  • Creating a branch, commit, or pull request from the work item
  • Specifying the work item ID during a commit, pull request, or other supported Git or TFVC operation
  • Specifically linking the work item from the Development section or Links tab to a source code branch, build, or other supported Git or TFVC operation.

Hovering over any entry listed under the Development section activates the hyperlink to the associated object.

The link types you can add within the development section are Branch, Build, Changeset, Commit, Found in build, Integrated in build, Pull Request, and Versioned Item.

Artifact-to-artifact link types

To learn more about the links control or to customize the Development links control, see LinksControlOptions elements, Development links control.