Exception of type 'Microsoft.TeamFoundation.Git.Contracts.GitCheckoutConflictException' was thrown

Issue

While trying to checkout to a new branch in Visual Studio 2019, I’m getting the below error:
enter image description here

I tried to do the same from GitBash cmd using the command git checkout branchname but here also, I’m getting an error:

error: The following untracked working tree files would be overwritten by checkout:
//list of file names below
...
...
...
Aborting

I tried restarting VS also but it was of no help. Can you please assist?

Solution

I had this same error and solved it the following way, note I am calling my branch as myBranchName…
Within visual studio in the git-manage branches screen, it just shows that error over and over. But, I navigated to the folder in windows, right-mouse context menu and chose ‘git bash here’ to open bash (which you can install along with GIT for windows in the same installer), in that folder. Then I typed

git checkout -b myBranchName

and pressed enter. This worked with no error.
Then I returned to visual studio and it showed myBranchName in the bottom right of the screen.

Note: Also this all assumes your "new branch name" is an existing branch, in my case it was an existing branch that existed already remotely and locally when I got that error. If this is different from your question, then this may/may not help.

Answered By – Chris

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published