Trying to undo/ignore by adding slnx.sqlite file in .git-ignore file in visual studio 2017,But still it shows uncommitted.

好久不见. 提交于 2021-02-07 14:31:33

问题


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

    `/.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` 

回答1:


it's showing up as uncommitted? If that's the case then adding it to .gitignore changes nothing because .gitignore only works for untracked files (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:

  • Keep the file on the project but specifically ask git to not care 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




回答2:


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.

For the slnx.sqlite, I just got rid off it completely like following:

git rm {PATH_OF_THE_FILE}/slnx.sqlite -f
git commit -m "remove slnx.sqlite"



回答3:


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>.




回答4:


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.

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.

Thanks



来源:https://stackoverflow.com/questions/44160735/trying-to-undo-ignore-by-adding-slnx-sqlite-file-in-git-ignore-file-in-visual-s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!