Thursday, October 29, 2015

If you add your SQL files to Visual Studio, you may want to remove the sql exclusion from gitignore

By Steve Endow

I'm not sure why I haven't run across this issue before--perhaps it has always happened and I didn't notice?

I recently migrated an old Visual Studio solution from SVN to Git in Visual Studio 2013.  After committing the project, I noticed that there were two files still listed under "Included Changes" of the Team Explorer tab.


Puzzled, I check the files in my solution.  They had the small blue plus sign next to them, indicating they had been added.

I tried to commit the solution again, but Visual Studio told me:

An error occurred. Detailed message: No changes; nothing to commit.

I Googled this, and not surprisingly, I ended up on a Stack Overflow thread discussing this issue.

It pointed me to the gitignore settings file and sure enough, there was the culprit.


And that explains why my SQL files were not committed.  Here is what my project looks like:


I have a folder named SQL where I store the SQL scripts related to the project.  I started doing this so that I could have a centralized place where all code, including SQL, could be tracked, versioned, and backed up.

So while I found the problem, it makes me wonder--why is sql/ excluded by default in the gitignore file?  This thread mentions that the SQL exclusion is apparently a "best practice", but there is no such reference in the docs, and I find that puzzling, at least in my situation.  Am I doing something wrong?  I can't imagine that it's some taboo practice to have a SQL folder in my project to store my SQL files.

What do other people do to manage their SQL scripts related to a project?

So now I have to go back through my other projects that I've setup with Git and see if the SQL folder and all of the SQL files have been ignored.  And I need to remember to modify my global gitignore on every one of my dev servers in my HyperV stable.

The learning never stops.  Maybe I need a Git sensei.


May you have many happy commits in your future.

Steve Endow is a Microsoft MVP for Dynamics GP and a Dynamics GP Certified IT Professional in Los Angeles.  He is the owner of Precipio Services, which provides Dynamics GP integrations, customizations, and automation solutions.

You can also find him on Google+ and Twitter




No comments:

Post a Comment