Git doesn't “see” App_Data in ASP.NET MVC4 web

2019-08-09 18:07发布

I was musing about whether to include the App_Data directory (of my ASP.NET MVC4 web application) in its repository when I noticed that it is already being ignored, even when there is no .gitignore file at all.

This is a new application that I just created and immediately initialized a repo. I tried creating another new application (from Visual Studio 2012), and got the same result. I also tried simply initializing a repo in a directory that I manually created. Here are my results (from bash prompt):

I'm on Windows 7 running msysgit with git version 1.8.1.2.

$ mkdir TEST

$ cd TEST

$ mkdir App_Data

$ ls
App_Data/

$ git init
Initialized empty Git repository in c:/Projects/TEST/.git/

$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

$ echo wtf...

Why is ignoring the App_Data directory?

标签: git
2条回答
Rolldiameter
2楼-- · 2019-08-09 18:38

Please mark above post as answer if that solved your issue.

I was having same problem, my repo was ignoring App_Data folder, where my database file (.sdf) was located. I tried adding .gitignore and it still did not work. I had to sync .sdf file so I did this,

  • Opened .gitignore
  • Find file type that you DO NOT want git to IGNORE (in my case the line was ' *.sdf ')
  • Remove the lines of your required file types, save the file.

Now your App_Data and its files/sub-directories should be visibe in repo.

查看更多
可以哭但决不认输i
3楼-- · 2019-08-09 18:44

Git is ignoring the App_Data directory because it is empty. Git works based on files rather than folders so ignores empty directories. A standard way to store an empty directory is to place a .gitignore or readme file in the folder and commit that.

查看更多
登录 后发表回答