Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 809
Craig Avatar asked Aug 03 '12 08:08

Craig


People also ask

How do I ignore files in Git using Visual Studio?

Open Visual Studio and the solution needing an ignore file. From the top menu select Git > Settings. The above will open Visual Studio's Options with Source Control > Git Global Settings selected. From the list on the left select Git Repository Settings and then click the Add button for Ignore file.

Where is Gitignore file in Visual Studio?

In the Visual Studio, click Git > Settings. This opens the Options window. Navigate to Source Control > Git Repository Settings. In the Git files section, click Add (next to Ignore file).

What is the difference between MDF and LDF?

MDF stands for Main Database File and contains all the information in a database. LDF records all the transactions and changes to the database. The ldf is critical for disaster recovery.

How do I add a Gitignore to an existing project in Visual Studio?

Open Visual Studio and the solution needing an ignore file. From the top menu select Git > Settings. The above will open Visual Studio's Options with Source Control > Git Global Settings selected. From the list on the left select Git Repository Settings and then click the Add button for Ignore file.

How to add gitignore in Visual Studio 2015?

In Visual Studio 2015 Team Explorer > Local Git Repositories > Project > Settings > Git > Repository Settings > Ignore & Attribute Files.You can add .gitignore file with items should be ignored in visual studio solutions by default.

How do I create a gitignore file for my repository?

You can create or edit your .gitignore file for your repo by going to the Settings view in Team Explorer, then selecting Repository Settings. Select Edit for your .gitignore. It automatically creates filters that will ignore all the VS specific build directories etc. More info have a look here. Show activity on this post.

Does Visual Studio auto-generate a manifest file for Git?

At least some Visual Studio versions auto-generate .manifest files when none is specified explicitly, therefore we used to ask Git to ignore them. However, we do have a beautiful .manifest file now: compat/win32/git.manifest, so neither does Visual Studio auto-generate a manifest for us, nor do we want Git to ignore the .manifest files anymore.

How do I add a git repository to Visual Studio?

In the Visual Studio, click Git > Settings. This opens the Options window. Navigate to Source Control > Git Repository Settings. In the Git files section, click Add (next to Ignore file ).


1 Answers

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.

like image 167
eckes Avatar answered Oct 14 '22 15:10

eckes