When someone runs git blame on a strange line of code months later, they ask "why is this here?". If the branch, commits, and pull request point back to a PBI, the answer is one click away: the requirement, the discussion, the acceptance criteria, and the Done video. If they don't, the context is lost.
Every branch, commit, and PR should be traceable to a PBI.
Git is distributed. A branch can be created in the GitHub UI, on the command line, by an IDE, or by an AI agent, so you can't rely on a tool to make the link for you. Put the PBI number where it travels with the code:
The first 2 are the most important, because they work no matter where the branch was created. Opening a draft PR straight away and linking it to the PBI also gives visibility, but it's a weaker substitute for a good branch name and good commit messages.
fix-loginFixed the bug❌ Figure: Bad example - Nothing points back to the PBI, so nobody knows why the change was made
bugfix/1234-login-fails-for-sso-users🐛 BUG - Fix SSO login redirect loop (#1234)✅ Figure: Good example - The branch, commit, and PR all carry the PBI number
The easiest way to link a branch to an issue is to create it from the issue itself. In the issue sidebar, under Development, click Create a branch. GitHub suggests a name starting with the issue number (e.g. 1234-login-fails-for-sso-users). Edit it to add a category prefix (e.g. bugfix/1234-login-fails-for-sso-users) so it follows your naming convention. The branch appears in the issue's Development section so anyone looking at the issue can see the work in progress.
From the command line, the GitHub CLI does the same thing:
gh issue develop 1234 --name bugfix/1234-login-fails-for-sso-users --checkout
See Creating a branch to work on an issue for details.
Note: Only branches created from the issue (or with gh issue develop) appear in the Development section. A branch created anywhere else isn't linked, which is why the branch name and commit messages still matter.
When a commit message or PR description contains #1234, GitHub autolinks it and adds a reference to the issue's timeline. The issue then shows every commit and PR that touched it.
Avoid closing keywords such as Closes #1234 or Fixes #1234. They close the issue as soon as the PR is merged (or the commit reaches the default branch), before the work is tested, deployed, and closed with context. Use a neutral phrase like Relates to #1234 instead. If your team links PRs from the Development sidebar, also turn off Auto-close issues with merged linked pull requests in the repository settings, as described in Do you avoid linking issues to PRs in GitHub?.
On plans that support them, ruleset metadata restrictions can require branch names and commit messages to match a pattern, such as one containing a PBI number.
❌ Figure: Bad example - No linked commits, branches, or pull requests
✅ Figure: Good example - Git branch linked to the PBI
If you create branches through Azure DevOps, you can link them to a work item during the creation process.
✅ Figure: Good example - Linking the PBI when creating the branch
In Azure Repos, a commit message containing #1234 links the commit to work item 1234. If your code is in GitHub and your backlog is in Azure Boards, use AB#1234 instead, as described in Link GitHub commits and pull requests to work items.
Learn more in Linking Work Items to Git Branches, Commits, and Pull Requests.
You can set up Branch Policies on your main branches to require linked work items on every pull request.
✅ Figure: Good example - Branch Policy on the main branch requiring linked work items on pull requests