Craig
Craig

Reputation: 36856

Visual Studio gitignore and mdf, ldf files

I have a database project that generates these files and added to gitignore. However they don't seem to be getting ignored and I need to revert them before commiting, quite annoying. The files are still locked by VS, is this a problem?

#
# Windows and Mac OS X Temp Cache Files
#
[Tt]humbs.db
*.DS_Store

#
#Visual Studio files
#
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.sdf
*.dbmdl
*.mdf
*.ldf
*.Database.dbmdl
ipch/
obj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/

#
#Tooling
#
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*

#
#Project files
#
[Bb]uild/

#
#Subversion files
#
.svn

#
# Microsoft Office Temp Files
#
~$*

#
# YoureOnTime specific files
#
YoureOnTime.Database.dbmdl


# End of File

Upvotes: 14

Views: 4857

Answers (1)

eckes
eckes

Reputation: 67177

I need to revert them before commiting

indicates that they are already versioned and were entered into .gitignore after they were added using git add.

Two possible solutions:

  1. temporarily take them out of your .gitignore, then
    git rm --cached -- *.mdf and
    git rm --cached -- *.ldf.
    This will remove the files from the index while keeping them on disk. When done,
    git commit -m "removing crap from repo" and restore your .gitignore.

  2. If you don't want to play around with your .gitignore, you could use update-index:
    git update-index --assume-unchanged -- *.mdf and
    git update-index --assume-unchanged -- *.ldf.
    This will force git to see the files as unchanged even if they were.

Upvotes: 24

Related Questions