12

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` 
Prashanth Bichala
  • 161
  • 1
  • 2
  • 8

6 Answers6

9

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

eftshift0
  • 26,375
  • 3
  • 36
  • 60
9

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"
curiousBoy
  • 6,334
  • 5
  • 48
  • 56
2

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

Grayson
  • 60
  • 8
  • The problem with removing it from index and moving forward (which is a valid solution) is that, when moving forward in time, if the file changes later on (and given that it's not being tracked because it's in .gitignore), if you try to go back to one of the revisions where the file is part of it, git will either complain or you will unwillingly modify it (if you do a checkout --force, for example). Just saying. – eftshift0 May 24 '17 at 14:19
  • More or less the same kind of problem as if we tell git to assume it's unchanged. The best approach is normally to remove it from the history of the branches (which has other consequences if people are already using those revisions... but anyway, another day of using git). – eftshift0 May 24 '17 at 14:21
  • for now i ll just commit it and later i ll remove it from previous commit's, thanks for spontaneous help@Edmundo – Prashanth Bichala May 24 '17 at 14:39
  • Yes, i have committed previously. Thanks for spontaneous help @Grayson – Prashanth Bichala May 24 '17 at 14:41
  • I would argue that for the vast majority of people, removing the file from the current commit and from the remote repo using the two commands above is perfectly adequate. Most people are not going to be rolling back their code by multiple versions in one go (if at all) so I wouldn't worry too much about that file being overwritten by rollback – Grayson May 24 '17 at 14:47
1

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

Jony Lalwani
  • 2,189
  • 2
  • 16
  • 14
1

I was getting the same when i created a new project in Visual Studio 2019. I added "2019" in following line in my gitignore file. This worked for me.

# Visual Studio 2015/2017/2019 cache/options directory
.vs/
KR Akhil
  • 877
  • 3
  • 15
  • 32
0
  1. Navigate to the directory of question in GitBash.
  2. Execute git rm --cached \.vs -f -r
Robert Green MBA
  • 1,834
  • 1
  • 22
  • 45