Conduct a Git pull request on Visual Studio Online

Andy Lewis

When you want people on your team to review code in a Git team project on Visual Studio Online, you can use a pull request to review and merge the code. Pull requests enable developers working in topic branches to get feedback on their changes from other developers prior to submitting the code into the master branch. Any developer participating in the review can see the code changes, leave comments in the code, and give a “thumbs up” approval if they’re satisfied with those changes.

Create a topic branch

Before you commit your code in Visual Studio, create a topic branch.

Adding the omlette.txt file.

Commit your changes to the topic branch.

Commit your changes

When you are ready to share your work, publish the branch.

Publish the branch

For example, Jamal creates his topic branch and pushes it to the server.

Create a pull request

Open the web portal.

In your web browser, create the pull request. Select your topic branch as the source and the branch you want to merge into as the target branch.

Click New Pull Request

Specify the title, description, and assign reviewers.

Edit the title, description, and reviewers

Conduct a pull request

Reviewers make comments on specific lines of code. If you want to be specific, select a specific block of code before inserting the comment.

Reviewers add general comments to the pull request.

Tip: To add a new line to a comment, press Shift+Enter.

All conversations and other events appear on the Discussion tab.

Team conducts a pull request

Make changes on the source branch

To act on the feedback, the requestor revises the code on their dev machine and pushes the changes so that reviewers can see them. For example, Jamal takes Raisa’s advice to change the color of the peppers.

Complete the pull request

Each reviewer approves or rejects the pull request.

A single approval is sufficient to approve the pull request. A single rejection overrides all approvals and causes the status to be rejected. When you approve or reject the pull request, team members are alerted if they have subscribed to alerts.

If the code in topic branch changes, your vote does not automatically change. So for example, if you approved the pull request but would want to re-check it if changes were made, you should make sure you stay notified about changes.

When the requestor and the reviewers are satisfied that the pull request is ready to merge, you can do it from the web browser.

After the merge, the target branch is updated with the changes from the topic branch.

After the merge, the topic branch (for example, jamal/breakfast) is still in the repository. To keep your repository from getting cluttered by obsolete branches, you can delete the topic branch in your web browser.

Your target branch has been updated and the topic branch has been deleted. All of the commits that were merged are still in the repo.

All the commits and comments in pull request are still available if you need to refer to them later.

Q&A

Q: How can I make sure I’m notified when a pull request is created or changed?

A: If you are in the team room, you’ll see notifications there.

If you want to be notified about new pull requests, changes, approvals, and rejections, then subscribe to email alerts.

Q: How do I see the full content of the file?

A: Select the file in the left pane.

To see changes inline:

Q: Why do I see “Target branch updated, retry merge”? What should I do about it?

A: If changes are pushed to the target branch during the pull request, retry the merge to make sure there are no conflicts.

If there are no conflicts, then you are ready to merge again.

If there are conflicts, see Q: Why do I see “Merge conflicts”? What should I do about it?

Q: Can I continue working on the target branch during the pull request? Can I merge changes from the target branch to the source branch?

A: Yes. For example, changes have been made on the jamal/breakfast source branch and on the raisa/breakfast target branch.

If you want to merge the changes from the target branch, pull the changes to your dev machine.

Next, merge the changes.

Q: Why do I see “Merge conflicts”? What should I do about it?

A: Conflicts can occur when you try to merge two branches. For example, a conflict often occurs when you merge two branches in which the same file is changed.

If you are trying to merge from source to target, you see merge conflicts in the pull request.

You are also blocked by the conflict if you try to merge from target to source.

After you merge the branches in Visual Studio, use the merge tool to resolve the conflicts.

Next, commit the merge.

Finally, push the merge.

Q: Why did a comment move or disappear?

A: Comments are anchored to the line number and column of the commit on which comment was made. That’s why comments can disappear or move in the discussion view.

Questions? Suggestions? Feedback?

I invite you to post:

0 comments

Discussion is closed.

Feedback usabilla icon