I've setup a GIT repository for a VS 2013 solution on visualstudio.com. The repository worked great while I was becoming accustomed to using TFS (in GIT mode).
Then I decided to familiarize myself with Branches, so I created a branch off of the master. I've made quite a few changes in this branch. I've committed the changes over time and have performed a Sync to push my local commits to the visualstudio.com repository. This all works.
The problem I am having is that I somehow lost the ability of switching back to the master branch. I cannot merge my newly created branch into the master. Every time I try to do anything that involves the master I get the following error in VS:
Cannot switch to master because there are uncommitted changes. Commit or undo your changes before you switch branches. See the Output window for details.
The Output window never contains any 'details'...
What "uncommitted changes" does this message refer to? Since I cannot get into the master branch I have no way of committing any of its changes (nor am I sure that I want to?). And the current (only other) branch I am in has been committed and sync'ed.
I'm really just learning TFS, GIT and source control. How do I safely recover from this problem?
Okay, I had the same issue myself as rwkiii - this is a bug in Visual studio and is not an easy one to fix. Here are the symptoms:
Visual Studio states that you cannot merge/switch braches/etc. because you have uncommitted changes - which is fine, except all your changes have been committed.
Here's a screenshot to be clearer.
If you look at the output window, it may appear empty but you have to change "Show output from" to "Source Control - Git". This will list the file that Visual Studio thinks has changes.
Now, things that I tried that didn't fix it (so you don't have to):
In the end, I had to go and delete the file from the disk, then "undo" that change from the Team Explorer window:
Not the most ideal solution, but it does seem to fix it.
I used the git command prompt to resolve the issue. I can't guarantee that it's the best way or the only way, but it worked for me in Visual Studio 2013.
Under Changes in the Team Explorer, choose Open Command Prompt.
In the command prompt type:
It will list the files that are open for change.
Copy off those files (just in case), then you can then discard the changes in the working directory in the command prompt.
Don't attempt to change branches in Visual Studio, it still won't work!
Instead at the command prompt switch to the branch in question.
When you go back to Visual Studio it will prompt you to reload the project. After that the branch will be updated correctly to the branch you chose from the command line.
hth
i faced same problem then i noticed the uncommitted changes are from different project. once i committed those changes, it allowed me branch change.
I had this issue after changing a filename from starting with a lower case letter to an upper case letter after I'd already committed the file. I fixed it by changing the name of the file (I just added a '1' on the end) and then committing that change. I was then able to switch branches.
As mentioned above, I had to change the 'Show output from:' combo to 'Source Control - Git' in the Output window in order to see the name of the offending file, that then showed me that the file name VS/git was expecting wasn't capitalised, where as the name in the solution explorer/on the file system was capitalised.
1: Open git bash
2: Point to your git repository
3: check you branch status by using command "
git status
"if you have any re usability of your changes for other branch then use "
git stash save
", (this will save your changes locally,you may face some conflict error, you can ignore for now) if you see any un-merged file in git status result and you want to keep the changes use "git add <file path>
"4: once your local changes are saved use command "
git reset --merge
"this will reset your local branch to the original checkout, now you are ready to switch the branch you may see the conflict files in visual studio Team Explorer>changes, if you don't want to keep that file changes right click and select undo changes or use "
git add <file path >
" to add this file with other saved files.5: Now your git branch is ready for switch, type "
git checkout <branch path>
"6: to pop saved changes use "
git stash pop
", this will merge the saved changes in you current branch.We regularly run into this issue, because we have a particular file which must always be excluded from changes, but sometime gets changed.
What works for us when the error message appears is:
git update-index --no-assume-unchanged TheNameOfTheFileCausingTheIssue
This may or may not work for your situation, but I have added it in case it puts someone in the right direction. Please be sure you understand the git command before running it!