Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 286
The Inquisitive Coder Avatar asked Sep 09 '25 18:09

The Inquisitive Coder


2 Answers

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.

like image 83
Chris Avatar answered Sep 12 '25 07:09

Chris


I was also facing the same issue and the below steps worked for me

  1. Navigated to \.git\refs\remotes folder in my local system
  2. Deleted the branch that was causing the issue
  3. Now i checked out the branch using git bash using git checkout <branchname>
like image 20
Sud Avatar answered Sep 12 '25 08:09

Sud