Visual Studio 2017 15.3.0 git 更改包括“storage.ide”,即使 .vs/ 在 .gitignore
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45802083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2017 15.3.0 git changes include "storage.ide" even though .vs/ in .gitignore
提问by Roger Layton
I upgraded VS 2017 to 15.3.0 a few days ago. Since then file "storage.ide" has remained in my modified files, even through I have used a suggested .gitignore for VS, which includes the .vs/ folder. This includes the following.
几天前我将 VS 2017 升级到 15.3.0。从那时起,文件“storage.ide”一直保留在我修改过的文件中,即使我使用了建议的 .gitignore 用于 VS,其中包括 .vs/ 文件夹。这包括以下内容。
# Visual Studio 2015 cache/options directory
.vs/
I then added the following to be more specific about ignoring this from the list of files to be tracked
然后我添加了以下内容以更具体地从要跟踪的文件列表中忽略它
.vs/SIASAWeb/v15/sqlite3/storage.ide
.vs/**/storage.ide
The Changes in the Team Explorer shows the following:
团队资源管理器中的更改显示以下内容:
<project folder>
.vs/<project>/v15/sqlite3
storage.ide
I have tried to git reset this file, but this then returns on the next commit, and also exists in all branches which I open, resulting in this then preventing the easy shift from one branch to another even if no changes were made.
我试图 git reset 这个文件,但是这会在下一次提交时返回,并且也存在于我打开的所有分支中,导致即使没有进行任何更改,也会阻止从一个分支轻松转移到另一个分支。
In the Solution Explorer the "applicationhost.config" and ".suo" files are marked as "ignored", but "storage.ide" is marked as "pending edit".
在解决方案资源管理器中,“applicationhost.config”和“.suo”文件被标记为“忽略”,但“storage.ide”被标记为“待编辑”。
I have tried committing, synced to the GitHub server, closing and re-opened VS, and even rebooting the computer.
我试过提交,同步到 GitHub 服务器,关闭并重新打开 VS,甚至重新启动计算机。
My question is why this file is being maintained as a modified file, even though it should be ignored for git.
我的问题是为什么这个文件被维护为一个修改过的文件,即使它应该被 git 忽略。
回答by Liam
To fix this, if you got to the Team Explorer tab and click on the Manage Connections button (the green one a the top) you will see a list of local Git Repositories.
要解决此问题,如果您进入 Team Explorer 选项卡并单击 Manage Connections 按钮(顶部的绿色按钮),您将看到本地 Git 存储库列表。
Right click on the repository you want to stop tracking the storage.ide file on and select Open Command Prompt.
右键单击要停止跟踪 storage.ide 文件的存储库,然后选择打开命令提示符。
You should then be able to type the following:
然后,您应该能够键入以下内容:
git rm --cached -r .vs
This removes the .vs folder and its contents and subdirectories from being tracked in git.
这会删除 .vs 文件夹及其内容和子目录,以免在 git 中被跟踪。
回答by Anthony Sottile
This probably means it was incorrectly added to the git repository at some point and then ignored afterwards. git will continue to track changes to gitignored files if they are present in the index ("checked in").
这可能意味着它在某个时候被错误地添加到 git 存储库中,然后被忽略了。如果 gitignored 文件存在于索引中(“签入”),git 将继续跟踪对 gitignored 文件的更改。
If you don't want the file checked in at all, you can remove it from the index by running
如果您根本不想签入该文件,则可以通过运行将其从索引中删除
git rm path/to-file --cached
This will keep the contents on disk, if you don't want the file to exist at all you can run
这会将内容保留在磁盘上,如果您根本不希望该文件存在,则可以运行
git rm path/to-file --force
Note that this may be undesirable if (for instance) the base project files are intended to be checked in as a starting point for working on the project. And you may just have to be careful about notcommitting that specific file.
请注意,如果(例如)打算将基本项目文件签入作为处理项目的起点,则这可能是不可取的。而且您可能只需要小心不要提交该特定文件。
回答by Noctis
the following seems to have solved the issue for me.
以下似乎为我解决了这个问题。
# Visual Studio 2015/2017 cache/options directory
*.vs/
it ignores everything in it.
它忽略其中的所有内容。
回答by Pierre-Olivier Morin
I just had the same issue. I solved it by making a whole new .gitignore
file from visual studio's team explorer (Team Explorer => Some git directory => Settings => Repository Settings => Gitignore file Add).
我只是有同样的问题。我通过.gitignore
从 Visual Studio 的团队资源管理器(团队资源管理器 => 一些 git 目录 => 设置 => 存储库设置 => Gitignore 文件添加)制作一个全新的文件来解决它。
Then I deleted my .vs
in my project folder and manually committed by git bash with the following lines:
然后我.vs
在我的项目文件夹中删除了我的,并通过 git bash 手动提交了以下几行:
git add *.*
git commit -m "Removing some files"
git push origin master
回答by José Alves
I'm using SourceTree(https://www.sourcetreeapp.com/) to manage my git commits. With it you can right click your changes and have an option of Stop Tracking.I used it for the same files you are trying to ignore as myself also just upgraded to 15.3.0 and that was the last time i saw those pending changes
我正在使用 SourceTree( https://www.sourcetreeapp.com/) 来管理我的 git 提交。有了它,您可以右键单击您的更改并选择停止跟踪。我将它用于您试图忽略的相同文件,因为我也刚刚升级到 15.3.0,这是我最后一次看到那些待处理的更改