Windows 上的 Git GUI 无法将 SQL (.sql) 文件识别为文本
如果这个问题已经得到解答,但我还没有找到答案,我深表歉意:(
我在 Windows 7 上使用 SQL Server Management Studio 2008。
我右键单击任何 sproc、函数或对象,然后选择“修改”。< br> 我单击“保存”并将文件保存到本地硬盘上的 git 存储库文件夹中。
我将文件保存为建议类型 =“Microsoft SQL Server 查询文件 (.sql)
所以现在我有一个文件,例如“MySproc.sql”,它在 SQL Management studio 中可以正常打开,但是当我使用 Git GUI 并进行“扫描”以查找修改的文件时,它将我的新“MySProc.sql”显示为“* 二进制文件” (不显示内容)。”而不是简单的文本。
我尝试在 NOtepad 中打开该文件并重新保存它,但这并没有解决问题。
任何帮助将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是猜测,但我想说你的 .sql 文件是 UTF-16;如果您将其保存为 UTF-8 或 ASCII,我想 git gui 可以正常使用它。
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.
这很烦人,但我所做的就是在上传更改之前将扩展名更改为 .txt。我认为 .sql 扩展名是导致 git 崩溃的原因。
PS 如果您正在使用 SQL Server Management Studio,这里有一个很有价值的提示。右键单击您的数据库。从弹出菜单中选择“任务”,然后选择“生成脚本”。这将带您进入一个向导,您可以在其中为数据库中的所有内容生成脚本。您可以将所有脚本输出到一个文件夹中。然后在提交更改之前使用 oscar's renamer 等程序将扩展名更改为 .txt 。这是向数据库添加源代码控制(尽管是手动的)的好方法。
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.
您还可以使用 powershell 将文件转换为 ASCII。
You can also use powershell to convert the file to ASCII.