Now that you are in a detached head state, feel free to run and test your code or even explore and commit changes. Once you confirm your action by clicking Yes, Visual Studio shows a confirmation message and both the Git Repository, and the Git Changes windows show a Detached at a Commit state. Meaning that the HEAD of your repository is going to point directly to a commit instead of a branch. Visual Studio shows a confirmation dialog explaining that by checking out a commit you will be in a detached HEAD state. To checkout a previous commit in Visual Studio, open the Git Repository window View > Git Repository, right click on the commit you would like to go back to and select checkout (–detach).
In this case, you can just checkout the tip of the remote branch that you would like to review. That way you don’t need to create a local branch if you are not planning on contributing to it. It can also be helpful if you would like to review code from a remote branch (a colleague’s branch, for example). For example, it allows you to go back to a previous point in your repository’s history where you can run or test your code. If you prefer an inline diff, you can use the diff configuration options gear and switch to an inline diff view.Ĭhecking out a commit can be beneficial in multiple ways.