How To Go To Master Branch in Git Updated on October 1, 2021 by Christopher Maiorana 1 Minutes, 57 Seconds to Read Are you having trouble getting back to the “master” branch in Git? This article focuses on how you can use different branches in Git, view your branches, and easily go back to your master branch. Using Git BranchesHow To View Git BranchesHow to Go To Master Branch in Git Using Git Branches Here is some additional context about Git branches, and how you can use them in your project. Or, if you just want to know how to get back to master you can skip ahead to that part of the article. Git allows for the creation of “branches” in your project, from which you can change files, create or delete files, and virtually change any aspect of your project without affecting the “master” branch. Changes from branches can be later “merged” into master, but until they are merged the changes remain completely separate from the status of the master branch. Branches are highly valuable when it comes to testing out fixes or changes to the code of your project. If you want to experiment with changes, additions, deletions, or refactoring in a completely non-destructive environment, creating a divergent Git branch is a great way to accomplish that. How To View Git Branches At any time in the course of your work you can easily view branches by running the git branch command: git branch In a new project with no additional branches, you will only see * master after running the git branch command. But, if you have multiple branches they will all be listed. * master Be sure to check out our full guide on creating and switching between branches in Git. How to Go To Master Branch in Git No matter which branch you are currently working in, you can always run the same command to get back to master: git checkout master You will then see a success message indicating that you successfully switched back to master: Switched to branch 'master' Remember, if you have uncommitted changes in the divergent branch then they will carry over when you switch back to master–however still in their dangling, uncommitted state. To avoid this, make sure to commit your changes to the divergent branch before checking out master. Well done! You now know how you can always get back to the master branch from any other branch in your Git project. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles How to Host a Static Site with GitHub Pages Publish Your Lovable Created React WebApp to InMotion Hosting Shared Hosting via GitHub How to Publish Your Lovable Created React WebApp to UltraStack ONE for React Git Checkout Command – How To Switch To Branches and Commits How to Create Your Own Git Server Using Git to Publish Files How to Create a New Account with GitHub How to Commit Changes in Git How to Sign Tags and Commits with Git Git Fundamentals Complete Beginner Guide