{"id":3223,"date":"2013-03-08T05:14:00","date_gmt":"2013-03-08T05:14:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2013\/03\/08\/use-the-git-command-prompt-to-supplement-visual-studio\/"},"modified":"2019-02-14T17:54:38","modified_gmt":"2019-02-15T01:54:38","slug":"use-the-git-command-prompt-to-supplement-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/use-the-git-command-prompt-to-supplement-visual-studio\/","title":{"rendered":"Use the Git command prompt to supplement Visual Studio"},"content":{"rendered":"<p>\/\/<\/p>\n<p>By: <a href=\"http:\/\/social.msdn.microsoft.com\/profile\/andy%20lewis%20-%20msft\/\">Andy Lewis<\/a> and <a href=\"http:\/\/social.msdn.microsoft.com\/profile\/matthew%20mitrik%20(ms)\/\">Matthew Mitrik<\/a><\/p>\n<p>In Visual Studio Tools for Git we aim to offer the fundamental features you need to develop an app in a Git version-controlled codebase. We explain how to perform these tasks in previous posts such as <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/02\/06\/set-up-connect-and-publish-using-visual-studio-with-git.aspx\">Create, Connect, and Publish using Visual Studio with Git<\/a> and in our <a href=\"http:\/\/tfs.visualstudio.com\/en-us\/learn\/code\/create-code-project-vs-git\/\">Git welcome portal content<\/a>.<\/p>\n<p>That said, there is a long tail of less-common tasks in software development work. If you can&#8217;t yet do what you want to do in VS, you might be able to do it from the command prompt. Also, many developers find the command prompt to be a handy and efficient way to perform repetitive tasks, either manually or with a script.<\/p>\n<p style=\"margin-bottom: 0\"><a class=\"expander\" style=\"padding: 2px;background-color: #dddddd;font-weight: bold\" href=\"#\">Got the latest version of Visual Studio with Git? If not, click here.<\/a><\/p>\n<div id=\"get-git\" class=\"expandable\" style=\"padding: 3px 5px 3px 15px;margin-left: 25px;background-color: #dddddd;margin-top: 0\">\n<p>To use the Visual Studio client tools you&#8217;ll need to <a href=\"http:\/\/go.microsoft.com\/fwlink\/p\/?LinkId=254509\">install Visual Studio 2012<\/a>, <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=273878\">apply Visual Studio 2012 Update 2<\/a>, and finally <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=275845\">install Visual Studio Tools for Git<\/a>. If you want to use Team Foundation Service, <a href=\"https:\/\/tfs.app.visualstudio.com\/_account\/Signup\">you can sign up for free<\/a>.<\/p>\n<\/div>\n<h2>Get set up to use the command prompt tools<\/h2>\n<h2>Enable basic authentication for your TFS account<\/h2>\n<p style=\"margin-bottom: 0\">If your repo is hosted in Team Foundation Service (TFS), then you must enable basic authentication before you can use the command prompt to fetch, pull, push, clone, etc. You can set this up from your User Profile in TFS. <a class=\"expander\" style=\"background-color: #dddddd;font-weight: bold\" href=\"#\">Show me.<\/a><\/p>\n<div id=\"basic-auth\" class=\"expandable\" style=\"padding: 3px 5px 3px 15px;margin-left: 25px;background-color: #dddddd;margin-top: 0\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/03\/4722.GitSettingsTFSProfileAltCreds.png\" alt=\"\" \/><\/div>\n<p><strong>Tip:<\/strong> To make using the command prompt less tedious (for example, to avoid having to enter your credentials every time you push), you might want to also install <a href=\"http:\/\/gitcredentialstore.codeplex.com\/\">Windows Credential Store for Git<\/a> on your dev machine.<\/p>\n<h2>Get the command prompt tools<\/h2>\n<p style=\"margin-bottom: 0\">If you have not already installed some command-prompt tools, you can get some quickly from Visual Studio. (One way you can tell that you don&#8217;t have the tools is if you try to enter a git command and get the <span style=\"font-family: 'Courier New',monospace,serif;background-color: black;color: white\">&#8216;git&#8217; is not recognized as an internal or external command&#8230;<\/span> message.) Go to the <strong>Settings <\/strong>page and click <strong>Install 3rd-party tools<\/strong>. <a class=\"expander\" style=\"background-color: #dddddd;font-weight: bold\" href=\"#\">Show me.<\/a><\/p>\n<div id=\"install-link\" class=\"expandable\" style=\"padding: 3px 5px 3px 15px;margin-left: 25px;background-color: #dddddd;margin-top: 0\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/03\/7824.GitCmdPromptInstallLink.png\" alt=\"\" \/><\/div>\n<p><strong>Tip: <\/strong>The install process drops a Git Bash<strong> <\/strong>icon on your desktop. You can delete this icon; we don&#8217;t believe this entry point leads to the best experience. And anyway, you can still get to it from Windows Start if for some reason you need it later.<\/p>\n<h2 style=\"margin-bottom: 0\">Open the Git command prompt window<\/h2>\n<p style=\"margin-bottom: 0\">You can open the command prompt from the Actions menu on the Changes, Commits, and Branches pages. You can also open it from the <strong>Connect <\/strong>page: Right-click your local repo, and then click <strong>Open Command Prompt<\/strong>. <a class=\"expander\" style=\"background-color: #dddddd;font-weight: bold\" href=\"#\">Show me.<\/a><\/p>\n<div id=\"open-window\" class=\"expandable\" style=\"padding: 3px 5px 3px 15px;margin-left: 25px;background-color: #dddddd;margin-top: 0\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/03\/1638.GitCmdPromptWindowOpen.png\" alt=\"\" \/><\/div>\n<h2>Work from the command prompt<\/h2>\n<p>We hope you find the following table to be a useful if not complete guide to some of the more common tasks. You can find more command-prompt reference information here: <a href=\"http:\/\/git-scm.com\/docs\">http:\/\/git-scm.com\/docs<\/a>.<\/p>\n<p><strong>Caution:<\/strong> If you are not an experienced Git user, use the command-prompt carefully. Make sure to research the command thoroughly before you use it.<\/p>\n<table style=\"border-collapse: collapse\">\n<thead style=\"font-weight: bold\">\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">Task<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">Visual Studio<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">Command Prompt<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Create a local repository<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/02\/06\/set-up-connect-and-publish-using-visual-studio-with-git.aspx\">Yes<\/a><\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-init\">git-init<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Copy a remote repository to your dev machine<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/02\/06\/set-up-connect-and-publish-using-visual-studio-with-git.aspx\">Yes<\/a><\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-clone\">git-clone<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Fetch and pull changes from a remote repository<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/tfs.visualstudio.com\/en-us\/learn\/code\/pull-vs-git\/\">Yes<\/a> (some conflicts can be resolved only at command prompt)<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-fetch\">git-fetch<\/a>, <a href=\"http:\/\/git-scm.com\/docs\/git-pull\">git-pull<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Get information about a repository<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">You can if it is in a TFS team project (<a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/02\/06\/set-up-connect-and-publish-using-visual-studio-with-git.aspx\">shown in bold text<\/a> and with hover info in Team Explorer)<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-remote\">git-remote<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Commit your changes<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/tfs.visualstudio.com\/en-us\/learn\/code\/commit-vs-git\/\">Yes<\/a><\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-commit\">git-commit<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Amend your last commit. Some typical cases:<\/p>\n<ul>\n<li>Add a file you wanted to include in the commit. See <a href=\"http:\/\/git-scm.com\/book\/en\/Git-Basics-Undoing-Things\">Undoing Things<\/a>.<\/li>\n<li>Modify a comment. For example, maybe you want to change &#8220;Fix a bug&#8221; to &#8220;Fix bug #32&#8221; in order to associate the commit with a work item when you push you changes to TFS. See <a href=\"http:\/\/stackoverflow.com\/questions\/179123\/how-do-i-edit-an-incorrect-commit-message-in-git\">How do I edit an incorrect commit message in Git?<\/a><\/li>\n<\/ul>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">No<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"https:\/\/www.kernel.org\/pub\/software\/scm\/git\/docs\/git-commit.html\">git-commit<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Undo a committed change by applying the inverse of the commit. See <a href=\"http:\/\/gitready.com\/intermediate\/2009\/03\/16\/rolling-back-changes-with-revert.html\">rolling back changes with revert<\/a>.<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">No<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"https:\/\/www.kernel.org\/pub\/software\/scm\/git\/docs\/git-revert.html\">git-revert<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Undo committed changes by returning your local repo to a prior commit and de-referencing the later commit.&nbsp; See <a href=\"http:\/\/git-scm.com\/book\/en\/Git-Basics-Undoing-Things\">Undoing Things<\/a>, which warns, &#8220;&#8230;this is a <strong>dangerous command<\/strong>: any changes you made to that file are gone &mdash; you just copied another file over it. Don&rsquo;t ever use this command unless you absolutely know that you don&rsquo;t want the file.&#8221;<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">No<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-reset\">git-reset<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Branch and merge<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">Yes (some conflicts can be resolved only at command prompt). (We plan to post more info on branches. For now, see our <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/01\/30\/getting-started-with-git-in-visual-studio-and-team-foundation-service.aspx\">announcement post<\/a>.)<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-branch\">git-branch<\/a>, <a href=\"http:\/\/git-scm.com\/docs\/git-merge\">git-merge<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Re-order history or combine commits. See <a href=\"http:\/\/git-scm.com\/book\/en\/Git-Branching-Rebasing\">Git Branching &#8211; Rebasing<\/a>.<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">No<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-rebase\">git-rebase<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\">\n<p>Push changes to a remote repository<\/p>\n<\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/tfs.visualstudio.com\/en-us\/learn\/code\/push-vs-git\/\">Yes<\/a><\/td>\n<td style=\"vertical-align: top;padding: 5px;border: solid 1px black\"><a href=\"http:\/\/git-scm.com\/docs\/git-push\">git-push<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&lt;!&#8211;<\/p>\n<h1 class=\"header-title\">Use the Git command prompt to supplement Visual Studio<\/h2>\n<p>&#8211;&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ By: Andy Lewis and Matthew Mitrik In Visual Studio Tools for Git we aim to offer the fundamental features you need to develop an app in a Git version-controlled codebase. We explain how to perform these tasks in previous posts such as Create, Connect, and Publish using Visual Studio with Git and in our [&hellip;]<\/p>\n","protected":false},"author":91,"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-3223","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-devops-server","category-devops","category-git"],"acf":[],"blog_post_summary":"<p>\/\/ By: Andy Lewis and Matthew Mitrik In Visual Studio Tools for Git we aim to offer the fundamental features you need to develop an app in a Git version-controlled codebase. We explain how to perform these tasks in previous posts such as Create, Connect, and Publish using Visual Studio with Git and in our [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/3223","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\/91"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=3223"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/3223\/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=3223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=3223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=3223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}