Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access denied writing to VS project .suo when trying to merge branches with TFS & GIT

I am trying to merge a branch with the master. Branch structure:

master
    v0.43

My important changes are in v0.43. After making a commit in v0.43 I attempt to merge v0.43 to master. I receive the following error:

An error occurred. Detailed message: An error was raised by libgit2. Category = Invalid (Error). Could not open 'C:/Users/Me/Source/Repos/MyüProject XXX/MyüProject XXX/XXX XXX X.v12.suo' for writing: Access is denied.

There is no additional information in the Output pane.

I also get the above error message when simply trying to change from the v0.43 branch to the master branch. Basically, I'm stuck in the v0.43 branch.

Please note that the "X"s obscure alpha characters in the actual project name. Are the spaces valid? Is ü valid? If the folder and file names are valid, and the special character is valid, why is Access Denied? Or should the merge need to access this file at all?

I understand it is a Visual Studio User Settings file. I am fairly sure it is not included in the GIT repository - though I have only checked with:

git ls-files *.suo

No files are returned.

Does this problem have anything to do with a conflict in credentials between TFS/GIT and settings in Visual Studio or Windows? Btw, I am running VS 2013.2 on Win 8.1.

I can't determine if the GIT branch merge really needs access to the VS User Settings file (.suo) or if this file shouldn't even need to be accessed. If it does require access, what could I try to make that happen? If this access isn't needed at all, why does it keep trying?

EDIT - Additional Info

I'm new to TFS/GIT. It's a lot to absorb. When I initially setup the repositories (local and TFS on visualstudio.com) the default .gitignore did not get created for some reason, apparently in my local repository? I don't know, but while I was making changes to my project and then making Commits I was seeing things showing up in "Excluded" and "Untracked". Being green to GIT/TFS, I right clicked and included these Excluded/Untracked files. I now know this was wrong.

I think I've recovered from the above problem. First, I implemented a default .gitignore that specifically ignores /bin and /obj. Then I removed everything within those two folders (via VS Solution Explorer). They did not come back up as Included, Excluded or Untracked. This fixed one issue.

Next issue was that I saw the project's .suo included in the v0.43 branch. I saw that it was supposed to be ignored in the default .gitignore (*.suo) and so I needed to remove it from the v0.43 branch, but it wasn't as easy as deleting unused files. I did it from the command line using:

I was able to see that the .suo existed using:

git ls-files *.suo

I removed it with:

git rm --cached "*.suo"
git commit -m "Delete *.suo file from repository"

... and I was/am able to confirm it was removed by performing the same ls-files command. It no longer shows up in the v0.43 branch. I made the commit and sync'd with TFS. Now I am getting the error noted above - Access is Denied to the .suo whenever I try to merge v0.43 to master or even switch to master branch.

Possibly it is the master branch that I am trying to switch TO that is trying to access the .suo file?

If that's the case, I'm totally stumped on how to resolve this. I suppose it is possible that the .suo got Committed to the master branch at some point... but I don't know how to safely access the master branch and remove the .suo from it like I did to v0.43 branch.

I hope this all makes sense. :S

like image 834
rwkiii Avatar asked Nov 15 '14 18:11

rwkiii


People also ask

How do I merge feature branches?

Merge branchesSelect the branch that you want to merge into the current branch, click Modify options and choose from the following: --no-ff : a merge commit will be created in all cases, even if the merge could be resolved as a fast-forward.

How do I keep both changes in merge conflict in Visual Studio?

If you need to keep all of your changes to a file, you can right-click it in the Unmerged Changes section and select Keep Current (Local) without having to open Merge Editor.


2 Answers

I got a very similar issue today. I couldn't switch branches because there was this error:

An error occurred. Detailed message: Could not open 'D:/Projects/ProjectName/Database/database.db' for writing: Access is denied.

Note: Pathname and filename renamed for display purposes

What I did was very simple

  • Remove the file from your file explorer (not in your project)
  • Git will now detect a deletion of this file
  • Undo this deletion in your Changes view

I'm not sure what caused this problem and I hope anyone finds this answer helpful.

like image 172
A1rPun Avatar answered Sep 23 '22 02:09

A1rPun


I'm working on this right now and believe this to be the answer to the problem-
The *.sou file is part of Visual Studio's user preferences. It's in the ".vs" folder that is a "hidden folder" along side your solution.

If you are using Team Services as your Git repository, then you just need to remove the ".vs" folder and it will be marked "Deleted/{folder}/.vs"

To delete the folder in Team Services: locate the project in Team Services, and hover over the "Code" drop down menu and select "Files". Navigate to the .sln folder and you will find the ".vs" folder. Delete that ".vs" folder by "righ-clicking" on it and selecting "Delete"

That folder should no longer be tracked.

like image 43
Dana Reed Avatar answered Sep 23 '22 02:09

Dana Reed