{"id":1063,"date":"2014-06-10T12:35:00","date_gmt":"2014-06-10T12:35:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2014\/06\/10\/conduct-a-git-pull-request-on-visual-studio-online\/"},"modified":"2019-02-14T17:48:56","modified_gmt":"2019-02-15T01:48:56","slug":"conduct-a-git-pull-request-on-visual-studio-online","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/conduct-a-git-pull-request-on-visual-studio-online\/","title":{"rendered":"Conduct a Git pull request on Visual Studio Online"},"content":{"rendered":"<p>When you want people on your team to review code in a <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/vstudio\/hh850436.aspx\">Git team project<\/a> on <a href=\"http:\/\/www.visualstudio.com\/\">Visual Studio Online<\/a>, 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 &#8220;thumbs up&#8221; approval if they&#8217;re satisfied with those changes.<\/p>\n<h2>Create a topic branch<\/h2>\n<p>Before you commit your code in Visual Studio, create a topic branch.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6242.VCtrlGitPullReqCreateTopicBranch.png\" alt=\"Adding the omlette.txt file.\" \/><\/p>\n<p>Commit your changes to the topic branch.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/4743.VCtrlGitPullReqTopicBranchSourceEdit1.png\" alt=\"Commit your changes\" \/><\/p>\n<p>When you are ready to share your work, publish the branch.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/3240.VCtrlGitPullReqTopicBranchSourcePublish.png\" alt=\"Publish the branch\" \/><\/p>\n<p>For example, Jamal creates his topic branch and pushes it to the server.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6433.VCtrlGitPullReqBranchC.png\" alt=\"\" \/><\/p>\n<h2>Create a pull request<\/h2>\n<p>Open the web portal.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/4555.VCtrlGitPullReqWebPortal.png\" alt=\"\" \/><\/p>\n<p>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.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/0246.VCtrlGitPullReqNew1.png\" alt=\"Click New Pull Request\" \/><\/p>\n<p>Specify the title, description, and assign reviewers.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/4405.VCtrlGitPullReqNew2.png\" alt=\"Edit the title, description, and reviewers\" \/><\/p>\n<h2>Conduct a pull request<\/h2>\n<p>Reviewers make comments on specific lines of code. If you want to be specific, select a specific block of code before inserting the comment.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/3644.VCtrlGitPullReqCommentAddSelection1.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/2870.VCtrlGitPullReqCommentAddSelection2.png\" alt=\"\" \/><\/p>\n<p>Reviewers add general comments to the pull request.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6354.VCtrlGitPullReqCommentAddDiscussion.png\" alt=\"\" \/><\/p>\n<p><strong>Tip:<\/strong> To add a new line to a comment, press Shift+Enter.<\/p>\n<p>All conversations and other events appear on the Discussion tab.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/3021.VCtrlGitPullReqResponse2-1.png\" alt=\"Team conducts a pull request\" \/><\/p>\n<h2>Make changes on the source branch<\/h2>\n<p>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&#8217;s advice to change the color of the peppers.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/1185.VCtrlGitPullReqSourceBranchChangePushedToTarget.png\" alt=\"\" \/><\/p>\n<h2>Complete the pull request<\/h2>\n<p>Each reviewer approves or rejects the pull request.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6303.VCtrlGitPullReqApprove.png\" alt=\"\" \/><\/p>\n<p>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.<\/p>\n<p>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 <a href=\"#notifications\">make sure you stay notified about changes<\/a>.<\/p>\n<p>When the requestor and the reviewers are satisfied that the pull request is ready to merge, you can do it from the web browser.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/5226.VCtrlGitPullReqBranchHReady.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6012.VCtrlGitPullReqResponse4Code.png\" alt=\"\" \/><\/p>\n<p>After the merge, the target branch is updated with the changes from the topic branch.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/7288.VCtrlGitPullReqBranchHMerged.png\" alt=\"\" \/><\/p>\n<p>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.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/1526.VCtrlGitPullReqClose.png\" alt=\"\" \/><\/p>\n<p>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.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/2553.VCtrlGitPullReqBranchH.png\" alt=\"\" \/><\/p>\n<p>All the commits and comments in pull request are still available if you need to refer to them later.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/1854.VCtrlGitPullReqClosed.png\" alt=\"\" \/><\/p>\n<h2>Q&amp;A<\/h2>\n<h2 id=\"notifications\">Q: How can I make sure I&#8217;m notified when a pull request is created or changed?<\/h2>\n<p><strong>A:<\/strong> If you are in the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/vstudio\/dn169471.aspx\">team room<\/a>, you&#8217;ll see notifications there.<\/p>\n<p>If you want to be notified about new pull requests, changes, approvals, and rejections, then subscribe to email alerts.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/0412.VCtrlGitPullReqAlert1.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/4477.VCtrlGitPullReqAlert2.png\" alt=\"\" \/><\/p>\n<h2>Q: How do I see the full content of the file?<\/h2>\n<p><strong>A:<\/strong> Select the file in the left pane.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/3122.VCtrlGitPullReqCompare1.png\" alt=\"\" \/><\/p>\n<p>To see changes inline:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6371.VCtrlGitPullReqCompare2.png\" alt=\"\" \/><\/p>\n<h2>Q: Why do I see &#8220;Target branch updated, retry merge&#8221;? What should I do about it?<\/h2>\n<p><strong>A:<\/strong> If changes are pushed to the target branch during the pull request, retry the merge to make sure there are no conflicts.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/8625.VCtrlGitPullReqTargetUpdated1.png\" alt=\"\" \/><\/p>\n<p>If there are no conflicts, then you are ready to merge again.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/7356.VCtrlGitPullReqTargetUpdated2.png\" alt=\"\" \/><\/p>\n<p>If there are conflicts, see <a href=\"#conflicts\">Q: Why do I see &#8220;Merge conflicts&#8221;? What should I do about it?<\/a><\/p>\n<h2>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?<\/h2>\n<p><strong>A:<\/strong> Yes. For example, changes have been made on the jamal\/breakfast source branch and on the raisa\/breakfast target branch.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/5722.VCtrlGitPullReqBranchCandD.png\" alt=\"\" \/><\/p>\n<p>If you want to merge the changes from the target branch, pull the changes to your dev machine.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/5621.VCtrlGitPullReqResponse2-3.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/1667.VCtrlGitPullReqBranchCandDPull.png\" alt=\"\" \/><\/p>\n<p>Next, merge the changes.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/3568.VCtrlGitPullReqResponse2-4.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6518.VCtrlGitPullReqBranchCandDMerge.png\" alt=\"\" \/><\/p>\n<h2 id=\"conflicts\">Q: Why do I see &#8220;Merge conflicts&#8221;? What should I do about it?<\/h2>\n<p><strong>A:<\/strong> 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.<\/p>\n<p>If you are trying to merge from source to target, you see merge conflicts in the pull request.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/4382.VCtrlGitPullReqResponse2-2.png\" alt=\"\" \/><\/p>\n<p>You are also blocked by the conflict if you try to merge from target to source.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/5582.VCtrlGitPullReqBranchCandDMergeConflict.png\" alt=\"\" \/><\/p>\n<p>After you merge the branches in Visual Studio, use the merge tool to resolve the conflicts.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6406.VCtrlGitPullReqResponse2-5.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6242.VCtrlGitPullReqResponse2-6.png\" alt=\"\" \/><\/p>\n<p>Next, commit the merge.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/6378.VCtrlGitPullReqResponse2-7.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/1207.VCtrlGitPullReqResponse2-8.png\" alt=\"\" \/><\/p>\n<p>Finally, push the merge.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/4370.VCtrlGitPullReqResponse2-9.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/06\/2768.VCtrlGitPullReqBranchCandDMergeConflictResolvedPush.png\" alt=\"\" \/><\/p>\n<h2>Q: Why did a comment move or disappear?<\/h2>\n<p><strong>A:<\/strong> Comments are anchored to the line number and column of the commit on which comment was made. That&#8217;s why comments can disappear or move in the discussion view.<\/p>\n<h2>Questions? Suggestions? Feedback?<\/h2>\n<p>I invite you to post:<\/p>\n<ul>\n<li><strong>Questions:<\/strong> <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-us\/home?forum=tfsversioncontrol\">http:\/\/social.msdn.microsoft.com\/Forums\/en-us\/home?forum=tfsversioncontrol<\/a>.<\/li>\n<li><strong>Suggestions:<\/strong> <a href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio\/category\/30925-team-foundation-server\">http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio\/category\/30925-team-foundation-server<\/a><\/li>\n<li><strong>Feedback<\/strong> about this blog post in the box below.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":73,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[253,1,225],"tags":[],"class_list":["post-1063","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-devops-server","category-devops","category-git"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/1063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/73"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=1063"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/1063\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=1063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=1063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=1063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}