尝试通过在 Visual Studio 2017 中的 .git-ignore 文件中添加 slnx.sqlite 文件来撤消/忽略,但它仍然显示未提交。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44160735/
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
Trying to undo/ignore by adding slnx.sqlite file in .git-ignore file in visual studio 2017,But still it shows uncommitted.
提问by Prashanth Bichala
as am working on a project in visual studio and am trying to commit the changes and i have added the files in the .gitignore which i do not want to commit them. as well as i have added /.vs/slnx.sqlite in the .gitignore file but still it is showing as an uncommitted file. what i have to do. Please help me with this problem
由于我正在 Visual Studio 中处理一个项目,并且正在尝试提交更改,并且我已在 .gitignore 中添加了我不想提交的文件。以及我在 .gitignore 文件中添加了 /.vs/slnx.sqlite 但它仍然显示为未提交的文件。我必须做什么。请帮我解决这个问题
`/.vs/angular2-research/v15
/.vs/config/applicationhost.config
/.vs/slnx.sqlite
/.vs/slnx.sqlite-journal
/cleanui/cleanui-admin-template-angular/node_modules
/cleanui/.vs
/.vs
slnx.sqlite
*.sqlite
/.vs/*.sqlite
.vs/*.sqlite`
采纳答案by eftshift0
it's showing up as uncommitted? If that's the case then adding it to .gitignore changes nothing because .gitignore only works for untrackedfiles (files that git hasn't been tracking so far.... if a file has already been committed on a previous revision [and therefore is part of HEAD] then .gitignore changes nothing).... so, two approaches are to be followed:
它显示为未提交?如果是这种情况,那么将其添加到 .gitignore 不会有任何改变,因为 .gitignore 仅适用于未跟踪的文件(git 到目前为止尚未跟踪的文件.... HEAD 的一部分] 然后 .gitignore 什么都没有改变)...所以,需要遵循两种方法:
Keep the file on the project but specifically ask git to notcare if it changes. Then you can do
git update-index --assume-unchanged somefile
Remove the file from the history of the branch. This is quite a different endeavor and requires rewriting the history of the branch (or branches) Completely remove file from all Git repository commit history
将文件保留在项目中,但特别要求 git不关心它是否更改。然后你可以做
git update-index --assume-unchanged somefile
从分支的历史记录中删除文件。这是一项完全不同的工作,需要重写一个(或多个)分支的历史记录从所有 Git 存储库提交历史记录中完全删除文件
回答by Grayson
You probably have the file staged. (Please post the results of git status
to clarify the exact problem). Try git reset <filePath>
. If that doesn't work, the file might have been committed previously and you could try git rm --cached <filePath>
.
您可能已暂存文件。(请发布结果git status
以澄清确切的问题)。试试git reset <filePath>
。如果这不起作用,则该文件可能之前已提交,您可以尝试git rm --cached <filePath>
.
回答by Jony Lalwani
You see the file in uncommitted changes because that file is already committed in Git repository and on a local build it has some changes again which shows up in uncommitted changed.
您会在未提交的更改中看到该文件,因为该文件已在 Git 存储库中提交,并且在本地构建中它再次有一些更改,这些更改显示在未提交的更改中。
To avoid this delete the file from local repo and push the changes to git server repo. gitignore works for only new files which are not yet in git repo.
为避免这种情况,请从本地存储库中删除文件并将更改推送到 git 服务器存储库。gitignore 仅适用于尚未在 git repo 中的新文件。
Thanks
谢谢
回答by curiousBoy
Just keep that in mind that those files stores some local user settings and preferences for projects (like what files you had open). So every time you navigate or do some changes in your IDE, that file is changed and therefore it checks it out and show as there are uncommitted changes.
请记住,这些文件存储了一些本地用户设置和项目首选项(例如您打开了哪些文件)。因此,每次您在 IDE 中导航或进行一些更改时,该文件都会更改,因此它会检查它并显示为有未提交的更改。
For the slnx.sqlite, I just got rid off it completely like following:
对于 slnx.sqlite,我刚刚完全摆脱了它,如下所示:
git rm {PATH_OF_THE_FILE}/slnx.sqlite -f
git commit -m "remove slnx.sqlite"