{"id":13696,"date":"2017-04-10T11:10:00","date_gmt":"2017-04-10T19:10:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=13696"},"modified":"2019-02-18T17:48:37","modified_gmt":"2019-02-18T17:48:37","slug":"visual-studio-for-teams-of-cpp-developers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/visual-studio-for-teams-of-cpp-developers\/","title":{"rendered":"Visual Studio for Teams of C++ Developers"},"content":{"rendered":"<p>In this blog post we will dive into how Visual Studio supports teams of C and C++ developers. We\u2019ll begin by creating a small C++ program and placing it in a Git repository in Visual Studio Team Services. Next we&#8217;ll see how to commit and push updates and get updates from others. Finally, we will work with GitHub repos using the GitHub extension for Visual Studio.<\/p>\n<h2>Adding an Existing C++ Project to Git in Visual Studio Team Services<\/h2>\n<p>In this example, you will create a small sample application and use Visual Studio to create a Git repository in Visual Studio Team Services. If you have an existing project, you can use it instead.<\/p>\n<p>To get started you&#8217;ll need an account on Visual Studio Team Services. Sign up for a free <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/setup-admin\/team-services\/sign-up-for-visual-studio-team-services#sign-up-for-visual-studio-team-services-with-a-personal-microsoft-account\">Visual Studio Team Services account<\/a>. You can use a personal, work or school account. During the process, a new default project may be created but will not be used in this example.<\/p>\n<ol>\n<li>Download the <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/CalculatingWithUnknowns.zip\">sample project<\/a> from <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/jumping-into-c-calculating-unknowns\/\"><\/a> and unzip it into a suitable working directory. You can also use one of your own C++ projects; the steps will be the same.<\/li>\n<li>Start Visual Studio 2017 and load the CalculatingWithUnknowns solution. Expand the <strong>Source Files<\/strong> node in <strong>Solution Explorer<\/strong> to see the solution files:\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/teams_solutions.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/teams_solutions.jpg\" alt=\"Visual Studio Solution Explorer showing project C++ source files\" width=\"465\" height=\"447\" class=\"aligncenter wp-image-13715 size-full\" \/><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/teams_solutions.jpg\"><\/a><\/li>\n<li>The blue status bar at the bottom of the Visual Studio window is where you perform Git-related tasks. Create a new local Git repo for your project by selecting <strong>Add to Source Control<\/strong> in the status bar and then selecting <strong>Git<\/strong> from the . This will create a new repo in the folder the solution is in and commit your code into that repo.<\/li>\n<li>You can select items in the status bar to quickly navigate between Git tasks in Team Explorer.\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar.jpg\" alt=\"Status bar showing four different Git tasks\" width=\"443\" height=\"25\" class=\"aligncenter wp-image-13755 size-full\" \/><\/a><\/p>\n<ol type=\"a\">\n<li>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_a.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_a.jpg\" alt=\"Up-arrow with two\" width=\"48\" height=\"25\" \/><\/a>\u00a0shows the number of unpublished commits in your local branch. Selecting this will open the <strong>Sync<\/strong> view in Team Explorer.<\/div>\n<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_b.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_b.jpg\" alt=\"Pencil with 0\" width=\"44\" height=\"25\" \/><\/a>\u00a0shows the number of uncommitted file changes. Selecting this will open the <strong>Changes<\/strong> view in Team Explorer.<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_c.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_c.jpg\" alt=\"Current repo is CalculatingWithUnknowns \" width=\"204\" height=\"25\" \/><\/a>\u00a0shows the current Git repo. Selecting this will open the <strong>Connect<\/strong> view in Team Explorer.<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_d.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/status_bar_d.jpg\" alt=\"Current Git branch is master\" width=\"90\" height=\"25\" \/><\/a>\u00a0shows your current Git branch. Selecting this displays a branch picker to quickly switch between Git branches or create new branches.<\/li>\n<\/ol>\n<\/li>\n<li>In the Sync view in Team Explorer, select the <strong>Publish Git Repo<\/strong> button under <strong>Publish to Visual Studio Team Services<\/strong>.\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/publish_to_vsts.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/publish_to_vsts.jpg\" alt=\"Sync view in Team Explorer with Publish Git Repo button highlighted in red\" width=\"445\" height=\"490\" class=\"aligncenter wp-image-13735 size-full\" \/><\/a><\/li>\n<li>Verify your email and select your account in the <strong>Account Url<\/strong> drop down. Enter your repository name (or accept the default, in this case <strong>CalculatingWithUnknowns<\/strong>) and select <strong>Publish Repository<\/strong>. Your code is now in a Team Services repo. You can view your code on the web by selecting <strong>See it on the web<\/strong>.<\/li>\n<\/ol>\n<p>As you write your code, your changes are automatically tracked by Visual Studio. Continue to the next section if you want to learn how to commit and track changes to code, push your changes and sync and get changes from other team members. You can also <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/continuous-integration-for-c-with-visual-studio-team-services\/\">configure your C++ project for continuous integration (CI) with Visual Studio Team Services<\/a>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/see_it_on_web.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/see_it_on_web.jpg\" alt=\"Team Explorer Home dialog highlighting the example, CalculatingWithUnknowns C++ project, was pushed and you can see it on the web.\" width=\"451\" height=\"136\" class=\"aligncenter wp-image-13745 size-full\" \/><\/a><\/p>\n<h2>Commit and Push Updates and Get Updates from Others<\/h2>\n<p>Code change is inevitable. Fortunately, Visual Studio 2017 makes it easy to connect to repositories like Git hosted in Visual Studio Team Services or elsewhere and make changes and get updates from other developers on your team.<\/p>\n<p>These examples use the same project you configured in the previous section. To commit and push updates:<\/p>\n<ol>\n<li>Make changes to your project. You can modify code, change settings, edit text files or change other files associated with the project and stored in the repository \u2013 Visual Studio will automatically track changes. You can view changes by right-clicking on a file in Solution Explorer then clicking <strong>View History<\/strong>, <strong>Compare with Unmodified<\/strong>, and\/or <strong>Blame (Annotate)<\/strong>.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/commit_a.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/commit_a-1024x490.jpg\" alt=\"C++ source file differences in CalculatingWithUnknowns.cpp.\" width=\"879\" height=\"421\" class=\"aligncenter wp-image-13816 size-large\" \/><\/a><\/p>\n<ol start=\"2\">\n<li>Commit changes to your local Git repository by selecting the <strong>pending changes icon<\/strong> from the status bar.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/commit_b.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/commit_b.jpg\" alt=\"Status bar showing one pending change in the C++ project\" width=\"450\" height=\"26\" class=\"aligncenter wp-image-13825 size-full\" \/><\/a><\/p>\n<ol start=\"3\">\n<li>On the <strong>Changes<\/strong> view in Team Explorer, add a message describing your update and commit your changes.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/commit_c.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/commit_c.jpg\" alt=\"Team Explore Changes dialog with a branch comment and the Commit All button highlighted\" width=\"453\" height=\"490\" class=\"aligncenter wp-image-13805 size-full\" \/><\/a><\/p>\n<ol start=\"4\">\n<li>Select the <strong>unpublished changes status bar icon<\/strong> or the <strong>Sync<\/strong> view in Team Explorer. Select <strong>Push<\/strong> to update your code in Team Services\/TFS.<\/li>\n<\/ol>\n<p>To sync your local repo with changes from your team as they make updates:<\/p>\n<ol>\n<li>From the <strong>Sync<\/strong> view in Team Explorer, fetch the commits that your team has made. Double-click a commit to view its file changes.<\/li>\n<li>Select <strong>Sync<\/strong> to merge the fetched commits into your local repo and then push any unpublished changes to Team Services.<\/li>\n<li>The changes from your team are now in your local repo and visible in Visual Studio.<\/li>\n<\/ol>\n<h2>Work with GitHub repos using the GitHub Extension for Visual Studio<\/h2>\n<p>The GitHub Extension for Visual Studio is the easiest way to connect your GitHub repositories in Visual Studio. With the GitHub Extension, you can clone repos in one click, create repositories and clone it in Visual Studio in one step, publish local work to GitHub, create and view pull requests in Visual Studio, create gists and more.<\/p>\n<p>In this section, we walk through installation, connecting to GitHub and cloning a repo.<\/p>\n<ol>\n<li>Install the GitHub Extension for Visual Studio. If you already have Visual Studio installed without the extension, you can <a href=\"https:\/\/visualstudio.github.com\/downloads\/GitHub.VisualStudio.vsix\">install the GitHub Extension<\/a> it from the Visual Studio GitHub site. You can also select it as part of the Visual Studio installation process. To install (or modify) with Visual Studio 2017, run the installer and click <strong>Individual components<\/strong> and then click <strong>GitHub extension for Visual Studio<\/strong> under Code tools, then proceed with other selections and installation (or modification):<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/github_a.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/github_a.jpg\" alt=\"Individual components in the installer with GitHub extension for Visual Studio selected\" width=\"416\" height=\"309\" class=\"aligncenter wp-image-13806 size-full\" \/><\/a><\/p>\n<ol start=\"2\">\n<li>On the <strong>Connect<\/strong> view of Team Explorer, expand the GitHub connection and select <strong>Sign In<\/strong>. Provide your GitHub credentials to complete sign in.<\/li>\n<\/ol>\n<p style=\"text-align: center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/github_b.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/github_b.jpg\" alt=\"Team Explorer Connect dialog with GitHub options including sign-in\" width=\"449\" height=\"190\" class=\"aligncenter wp-image-13807 size-full\" \/><\/a><\/p>\n<ol start=\"3\">\n<li>Click <strong>Clone<\/strong> to bring up a dialog that shows all the repositories you can access. If you want to clone one, select it and then click <strong>Clone<\/strong>.<\/li>\n<li>To create a new repo, click <strong>Create<\/strong> and provide information about the repository. You can choose among several Git ignore preferences and licenses and choose whether your repo is public or private. If you have a private account, you will be restricted to private repositories.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/github_c.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/github_c.jpg\" alt=\"Create a GitHub Repository dialog\" width=\"502\" height=\"542\" class=\"aligncenter wp-image-13835 size-full\" \/><\/a><\/p>\n<ol start=\"5\">\n<li>To publish an existing project on your machine, click on the <strong>Sync<\/strong> tab in the <strong>Team Explorer<\/strong> window to get to the <strong>Publish to GitHub<\/strong><\/li>\n<\/ol>\n<p>To learn more about the extension, visit the <a href=\"https:\/\/visualstudio.github.com\/\">GitHub Extension for Visual Studio<\/a> page.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post we will dive into how Visual Studio supports teams of C and C++ developers. We\u2019ll begin by creating a small C++ program and placing it in a Git repository in Visual Studio Team Services. Next we&#8217;ll see how to commit and push updates and get updates from others. Finally, we will [&hellip;]<\/p>\n","protected":false},"author":264,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13696","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>In this blog post we will dive into how Visual Studio supports teams of C and C++ developers. We\u2019ll begin by creating a small C++ program and placing it in a Git repository in Visual Studio Team Services. Next we&#8217;ll see how to commit and push updates and get updates from others. Finally, we will [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/13696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/264"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=13696"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/13696\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=13696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=13696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=13696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}