{"id":14678,"date":"2025-10-10T13:15:15","date_gmt":"2025-10-10T13:15:15","guid":{"rendered":"https:\/\/www.bodhost.com\/kb\/?p=14678"},"modified":"2026-02-26T14:02:06","modified_gmt":"2026-02-26T14:02:06","slug":"how-to-switch-to-the-master-branch-in-git","status":"publish","type":"post","link":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/","title":{"rendered":"How to Switch to the Master Branch in Git"},"content":{"rendered":"<p>When working with Git, branches allow developers to work on different features or fixes without affecting the main project code. The master branch (or main branch in newer repositories) is typically the default branch where production-ready code resides.<\/p>\n<p>This guide explains how to switch to the master branch in Git using simple command-line instructions.<\/p>\n<p><strong>To switch to the master branch in Git, follow the steps below:<\/strong><\/p>\n<ol>\n<li>Open your terminal or command prompt.<\/li>\n<li>Navigate to your Git repository using the cd command.\n<pre>cd your-repository-name<\/pre>\n<\/li>\n<li>Check which branch you are currently on:\n<pre>git branch<\/pre>\n<p>The branch with an asterisk (*) next to it is your current branch.<\/li>\n<li>Switch to the master branch:\n<pre>git checkout master<\/pre>\n<\/li>\n<li>If your repository uses main instead of master, use:\n<pre>git checkout main<\/pre>\n<\/li>\n<li>If the master branch doesn\u2019t exist locally, create and switch to it:\n<pre>git checkout -b master<\/pre>\n<\/li>\n<\/ol>\n<p>This way, you have successfully switched to the master branch in Git.\u00a0 <!--StartFragment --><span class=\"cf0\">To prevent losing work, always submit or store your changes before switching branches. Remember that some repositories now use &#8216;main&#8217; as the default branch name; the same process applies when switching to it.<\/span><!--EndFragment --><!--EndFragment --><\/p>\n<p>Learn the full guide on <a href=\"https:\/\/www.bodhost.com\/kb\/how-to-install-git-on-windows-10\/\" target=\"_blank\" rel=\"noopener\"><em>how to install Git on Windows 10<\/em><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with Git, branches allow developers to work on different features or fixes without affecting the main project code. The master branch (or main branch in newer repositories) is typically the default branch where production-ready code resides. This guide explains how to switch to the master branch in Git using simple command-line instructions. To [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[837],"tags":[1654],"class_list":["post-14678","post","type-post","status-publish","format-standard","hentry","category-tutorial","tag-switch-to-the-master-branch-in-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Go To Master Branch in Git<\/title>\n<meta name=\"description\" content=\"Learn how to switch to the master branch in Git using simple commands. Follow these quick steps to check out or create the master branch.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Go To Master Branch in Git\" \/>\n<meta property=\"og:description\" content=\"Learn how to switch to the master branch in Git using simple commands. Follow these quick steps to check out or create the master branch.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base - bodHOST\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-10T13:15:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T14:02:06+00:00\" \/>\n<meta name=\"author\" content=\"Serena\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Serena\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/\"},\"author\":{\"name\":\"Serena\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/ffd3f118493c99471ae5bd4790a55830\"},\"headline\":\"How to Switch to the Master Branch in Git\",\"datePublished\":\"2025-10-10T13:15:15+00:00\",\"dateModified\":\"2026-02-26T14:02:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/\"},\"wordCount\":192,\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"keywords\":[\"Switch to the Master Branch in Git\"],\"articleSection\":[\"Tutorial\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/\",\"name\":\"How To Go To Master Branch in Git\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\"},\"datePublished\":\"2025-10-10T13:15:15+00:00\",\"dateModified\":\"2026-02-26T14:02:06+00:00\",\"description\":\"Learn how to switch to the master branch in Git using simple commands. Follow these quick steps to check out or create the master branch.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-switch-to-the-master-branch-in-git\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Tutorial\",\"item\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/category\\\/tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Switch to the Master Branch in Git\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"alternateName\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"contentUrl\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"width\":240,\"height\":240,\"caption\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\"},\"image\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/ffd3f118493c99471ae5bd4790a55830\",\"name\":\"Serena\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g\",\"caption\":\"Serena\"},\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/author\\\/seema\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Go To Master Branch in Git","description":"Learn how to switch to the master branch in Git using simple commands. Follow these quick steps to check out or create the master branch.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/","og_locale":"en_US","og_type":"article","og_title":"How To Go To Master Branch in Git","og_description":"Learn how to switch to the master branch in Git using simple commands. Follow these quick steps to check out or create the master branch.","og_url":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/","og_site_name":"Knowledge Base - bodHOST","article_published_time":"2025-10-10T13:15:15+00:00","article_modified_time":"2026-02-26T14:02:06+00:00","author":"Serena","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Serena","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/#article","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/"},"author":{"name":"Serena","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/ffd3f118493c99471ae5bd4790a55830"},"headline":"How to Switch to the Master Branch in Git","datePublished":"2025-10-10T13:15:15+00:00","dateModified":"2026-02-26T14:02:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/"},"wordCount":192,"publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"keywords":["Switch to the Master Branch in Git"],"articleSection":["Tutorial"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/","url":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/","name":"How To Go To Master Branch in Git","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/#website"},"datePublished":"2025-10-10T13:15:15+00:00","dateModified":"2026-02-26T14:02:06+00:00","description":"Learn how to switch to the master branch in Git using simple commands. Follow these quick steps to check out or create the master branch.","breadcrumb":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bodhost.com\/kb\/how-to-switch-to-the-master-branch-in-git\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Tutorial","item":"https:\/\/www.bodhost.com\/kb\/category\/tutorial\/"},{"@type":"ListItem","position":2,"name":"How to Switch to the Master Branch in Git"}]},{"@type":"WebSite","@id":"https:\/\/www.bodhost.com\/kb\/#website","url":"https:\/\/www.bodhost.com\/kb\/","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","description":"","publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"alternateName":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bodhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.bodhost.com\/kb\/#organization","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","url":"https:\/\/www.bodhost.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","contentUrl":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","width":240,"height":240,"caption":"Web Hosting Knowledge Base | bodHOST Hosting FAQ"},"image":{"@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/ffd3f118493c99471ae5bd4790a55830","name":"Serena","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g","caption":"Serena"},"url":"https:\/\/www.bodhost.com\/kb\/author\/seema\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/14678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/comments?post=14678"}],"version-history":[{"count":4,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/14678\/revisions"}],"predecessor-version":[{"id":14684,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/14678\/revisions\/14684"}],"wp:attachment":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/media?parent=14678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/categories?post=14678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/tags?post=14678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}