我有一个生成这些文件并添加到 gitignore 的数据库项目。然而,它们似乎并没有被忽略,我需要在提交之前恢复它们,这很烦人。文件仍然被 VS 锁定,这是一个问题吗?
#
# 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
最佳答案
I need to revert them before commiting
表示它们已经被版本化并被输入到 .gitignore
之后它们是使用 git add
添加的。
两种可能的解决方案:
暂时将它们从你的
.gitignore
中取出,然后
git rm --cached -- *.mdf
和
git rm --cached -- *.ldf
.
这将从索引中删除文件,同时 keeping them on disk .完成后,
git commit -m "removing crap from repo"
并恢复你的.gitignore
。如果你不想玩弄你的
.gitignore
,你可以使用update-index
:
git update-index --assume-unchanged -- *.mdf
和
git update-index --assume-unchanged -- *.ldf
.
这将强制 git 将文件视为未更改,即使它们是未更改的。
关于visual-studio-2010 - Visual Studio gitignore 和 mdf、ldf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11792461/