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:

  • pull specific commit/file from git
  • git shelving to remote repository
  • Travis-CI skipping deployment although Commit is tagged
  • gitlab-shell: Disallowed command
  • Get a graph/data that shows (last 1 year) on code checkins
  • Squashing and reorganizing commits
  • 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

  • Git: Recover from failed rebase
  • git: error: src refspec master does not match any
  • Using NODE_PATH with Git submodules
  • How to git clone an SVN repository where all branches are located in root?
  • Jenkins builds on tag pushes via gerrit-trigger plugin
  • How to use gitk with msys2?
  • 3 Solutions collect form web for “Access denied writing to VS project .suo when trying to merge branches with TFS & GIT”

    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.

    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.

    I also get this situation sometime but there is a simple solution for this.

    Just delete the .suo file from your project folder

    • goto solution explorer and right click on solution and choose second last option named ‘open folder in file explorer’.

      enter image description here

    • After that goto .vs folder(This is a hidden folder).

    • After that open folder, that has a name of your project.

    • Then delete the .sou file in that folder.

    • It’s done.

    • Open your visual studio and you see your problem is solved.

    Thank you,
    Nishit Zinzuvadiya.

    Git Baby is a git and github fan, let's start git clone.