2

i am working with vs2013 IDE. my web project has app_data folder and in which i have database testdb.mdf. so when i commit and check github site then i saw app_data folder was not there. it means app_data folder not published to github.

i read this post Git doesn't "see" App_Data in ASP.NET MVC4 web application

i copy a empty text file in app_data folder and do the commit and sync again then i saw app_data folder was there in github but my database files testdb.mdf file was not in app_data folder of github. why testdb.mdf file is not going to github?

suggest me how could i push my db file in app_data folder to github site.what to change in gitignore file.

Monojit Sarkar
  • 2,353
  • 8
  • 43
  • 94
  • Can you share your .gitignore configuration? – Epoch Feb 18 '18 at 19:01
  • gitignore file content is big. So should i post the full content here? Can you tell me any section name of gitignore file which would be small and i can post here. – Monojit Sarkar Feb 19 '18 at 05:12
  • If your project is on GitHub, the .gitignore file should have been pushed with your project even if it's missing other items. If the repo is public, post the link and I'll take a look. Make sure you aren't ignoring any lines like `app*` or `*_data` which would wildcard the folder into the ignore list. If you are, try adding `!app_data/` to exclude it if it is being tagged for some reason. Check for those inputs and try the exclusion, that may be enough to solve the problem. – Epoch Feb 19 '18 at 12:45
  • have a look my gitignore file...here is link https://github.com/karlosRivera/ASP.NET-MVC-EF-Sorting-Searching-and-Paging/blob/master/.gitignore tell me what to add in ignore file as result my mdf file should upload to github. – Monojit Sarkar Feb 19 '18 at 15:16
  • Just so I don't leave you hanging: I don't see anything wrong with your .gitignore file. I even ran a couple of tests on my local drive to emulate the error - the only time git doesn't recognize app_data while using your file is when app_data is *totally* empty. When I put any .mdf file in there, even a completely blank one beginning with a period or underscore, it still detects the file through git. When you remove the .gitignore file does it detect the folder? – Epoch Feb 19 '18 at 16:31

2 Answers2

1

Having checked your .gitignore file, there's no reason it shouldn't be detecting the app_data folder as long as it isn't empty. I discovered this post where someone mentions:

If you're using Server Explorer from Visual Studio, just right click on your Connection name in the Server Explorer window and click on Close Connection.

If your .mdf file is in use through a server or connection, it would cause a read-access error preventing git from tracking the file - thus causing it to think app_data is empty even though it isn't. Try ensuring your database file isn't being used by any other sources and see if git recognizes it then.

Epoch
  • 656
  • 4
  • 16
  • Sorry did not worked even delete db ref from server explorer and commit. – Monojit Sarkar Feb 19 '18 at 17:14
  • If you try to move the file to another location (ex. outside of the folder) does your computer throw any warnings or errors? – Epoch Feb 19 '18 at 17:39
  • i put the db file in db folder within project solution and when commit then i saw do folder with db file uploaded to github but app_data folder not going to upload to github.....not clear the reason. – Monojit Sarkar Feb 19 '18 at 18:03
0

Right click your mdf file (in App_data) and click on option 'Add ignored file to source control'. Notice that now the round red icon on your db file changed to the '+' symbol. You will be able to push/commit this file to git.

Mohammed Hameed
  • 73
  • 1
  • 10