Search code examples
gitvisual-studiosolution

Rename of Visual Studio Solution Loses Git Tracked Changes


When I rename my Git controlled Visual Studio solution, I lose all the changes. An error appears in the output window that says something like <new-solution-name>.VC.opendb can't be opened. What's going wrong?


Solution

  • The problem is that Visual Studio doesn't rename all the solution related files. The fix is to edit .gitignore (manually or within VS) to rename the missed files. The missed files will have the old solution name. Rename them to the new name.

    Before:

    /<old-solution-name>.VC.VC.opendb
    /<old-solution-name>.VC.db
    /<old-solution-name>.sln
    

    After:

    /<new-solution-name>.VC.VC.opendb
    /<new-solution-name>.VC.db
    /<new-solution-name>.sln