Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git GUI on windows not recognizing SQL (.sql) file as text

Apologies if this has been answered already but I have yet been unable to find an answer :(

I'm using SQL Server Management Studio 2008 on Windows 7 box.

I right-click any sproc, function or object and choose "Modify".
I click "Save" and save the file to a folder that is a git repository on my local hard drive.
I save the file as suggested type = "Microsoft SQL Server Query File (.sql)
So now I have a file e.g. "MySproc.sql" which opens fine in SQL Management studio, however when I use Git GUI and do a "scan" to find modified files it presents my new "MySProc.sql" as "* Binary file (not showing content)." instead of simple text.

I've tried opening the file in NOtepad and re-saving it but that did not fix it.

Any help would be greatly appreciated.

like image 321
Andre Avatar asked May 05 '11 16:05

Andre


People also ask

Why does git think my .SQL file is a binary file?

"Why is Git marking my file as binary?" The answer is because it's seeing a NUL (0) byte somewhere within the first 8000 characters of the file.

How to use Git Gui to Clone repository?

Getting started with Git GUI In order for this new repository to be initialized, you must first create a file, any file, in your local repo. Then, you must Commit and Push to the remote Git repository location. In order to clone a repository, click on the “Clone Existing Repository” link in the Git GUI window.

Are. SQL files binary?

sql file is a binary file.

How to Commit using Git Gui?

Start “Git Commit Tool” with a right click, stage the file by clicking on the icon next to the filename, add a message and the click commit. Open Git history from the Git Gui, choose the “Repository” menu, “Visualize master's history”. Notice that you have two commits now, and the second one has your name on it.


2 Answers

Just a guess, but I would say your .sql file is UTF-16; If you were to save it as UTF-8 or ASCII, I imagine git gui would work properly with it.

like image 82
Chris Shaffer Avatar answered Sep 19 '22 23:09

Chris Shaffer


It is annoying, but what I do is change the extension to .txt before uploading changes. I think the .sql extension is what is tripping up git.

P.S. Here's a valuable tip if you are using SQL Server Management Studio. Right click on your database. Choose Tasks from the popup menu and then Generate Scripts. That brings you into a wizard where you can generate scripts for everything in your database. You can output all scripts into a single folder. Then use a program like oscar's renamer to change the extension to .txt before you commit your changes. It is a great way to add source control (albeit manual) to your database.

like image 32
paulstamant Avatar answered Sep 20 '22 23:09

paulstamant