admin 管理员组文章数量: 887021
mac azure git
Azure Data Studio is a tool for both developers and database administrators with exciting features. You can install ADS on both Windows and Linux platforms. You can go through various Azure Data Studio articles on SQLShack to be comfortable with the tool and its features.
Azure Data Studio是具有激动人心功能的面向开发人员和数据库管理员的工具。 您可以在Windows和Linux平台上安装ADS。 您可以阅读有关SQLShack的各种Azure Data Studio文章,以熟悉该工具及其功能。
Source version control is a valuable part of IT developments. Suppose you are a developer and working on a database project. As part of your task, you might need to make specific changes in the database objects such as stored procedures, tables, functions. Your colleagues might be working on a separate project that affects the same objects. You should be aware of all these changes.
源代码版本控制是IT开发的重要组成部分。 假设您是一名开发人员,并且正在从事数据库项目。 作为任务的一部分,您可能需要对数据库对象(例如存储过程,表,函数)进行特定更改。 您的同事可能正在从事影响相同对象的单独项目。 您应该注意所有这些更改。
Similarly, recently someone deployed a stored procedure change in a critical production database. Your manager wants to know the history of changes to this procedure. You need information such as change date, what change was performed in the script, or make a comparison between the current stage and previous change.
同样,最近有人在关键生产数据库中部署了存储过程更改。 您的经理想知道此程序的更改历史。 您需要信息,例如更改日期,在脚本中执行了哪些更改,或者在当前阶段和上一更改之间进行比较。
Source control allows you to have a centralized location for all your database scripts, their versions, compare object versions, and commit or rollback the changes. You might have heard about the opensource and distributed version control system – GitHub. It is a useful tool for developers to store all modifications in a single place. They can download the current version, make changes, upload the new version for everyone’s visibility.
通过源代码控制,您可以为所有数据库脚本,它们的版本,比较对象版本以及提交或回滚更改提供一个集中的位置。 您可能已经听说过开源和分布式版本控制系统GitHub。 对于开发人员而言,这是一个有用的工具,可将所有修改都存储在一个地方。 他们可以下载当前版本,进行更改,上传新版本,以供所有人查看。
Azure Data Studio integrates Source control functionality for this purpose. In this article, we will explore the source control Git repository integration with ADS.
为此,Azure Data Studio集成了源代码管理功能。 在本文中,我们将探讨源代码控制Git存储库与ADS的集成。
先决条件: (Pre-requisite: )
You should always use the latest version for Azure Data Studio. I use ADS version 1.19.0 released on 15th June 2020. You can download it from the Microsoft Docs.
您应该始终使用最新版本的Azure Data Studio。 我使用的是2020年6月15 日发布的ADS版本1.19.0。您可以从Microsoft Docs下载它。
Azure Data Studio中的Git存储库 (Git Repository in Azure Data Studio)
Launch ADS and navigate to the highlighted Source Control icon. You can also use shortcut key Ctrl+ Shift + G.
启动ADS并导航到突出显示的Source Control图标。 您也可以使用快捷键Ctrl + Shift +G。
You can see it gives a message to me that a valid git installation is not found on my system. We need to install Git locally before start using source control:
您会看到它向我显示一条消息,即在我的系统上找不到有效的git安装。 在开始使用源代码管理之前,我们需要在本地安装Git:
Click on the hyperlink install git. It opens an external website, so ADS requires your permission to open it. It requires an active internet connection:
单击超链接安装git。 它会打开一个外部网站,因此ADS需要您的许可才能打开它。 它需要有效的互联网连接:
In the git web page, you can download the latest version for Windows from the link highlighted:
在git网页中,您可以从突出显示的链接中下载Windows的最新版本:
Click on the Download 2.27.0 for Windows, and it starts downloading the EXE file of Git.
单击Windows的Download 2.27.0,它开始下载Git的EXE文件。
安装Git源代码控制 (Installation of Git source control )
Once the Git installation file is downloaded, launch the setup. The first step is to accept the GNU general public license:
下载Git安装文件后,启动安装程序。 第一步是接受GNU通用公共许可证:
In the next step, specify the directory for the Git installation in your local system. By default, it installs Git in the program files of the root drive. You can modify the directory as per your requirement:
在下一步中,指定本地系统中Git安装的目录。 默认情况下,它将Git安装在根驱动器的程序文件中。 您可以根据需要修改目录:
Now, select the components for the Git installation. It installs Git Bash and Git GUI for the Windows Explorer integration. We can use the default components and proceed with the next step:
现在,选择用于Git安装的组件。 它会为Windows资源管理器集成安装Git Bash和Git GUI。 我们可以使用默认组件,然后继续下一步:
By default, Git uses Vim as the default editor. You can change it to Visual Studio Code, Notepad++, Atom from the drop-down. I use the default Vim editor for this article:
默认情况下,Git使用Vim作为默认编辑器。 您可以从下拉列表中将其更改为Visual Studio Code,Notepad ++,Atom。 我在本文中使用默认的Vim编辑器:
You can choose the Git usage from the Git bash only or also from the 3rd party software. In this article, we use Git in Azure Data Studio. You must select the option – Git from the command line and also from the 3rd party software:
您可以选择仅或者也可以从第三方软件Git的bash的Git的使用情况。 在本文中,我们在Azure Data Studio中使用Git。 :在命令行Git和也从第3方软件 -你必须选择选项
In the next step, choose the default option – Use the OpenSSL Library:
在下一步中,选择默认选项– 使用OpenSSL库:
It also allows configuring the line ending styles. We can go ahead with the default option here:
它还允许配置行尾样式。 我们可以在这里继续使用默认选项:
Now, configure the terminal emulator to use with the Git Bash. Choose the Windows default console – Command Prompt for this purpose:
现在,配置终端仿真器以与Git Bash一起使用。 为此,请选择Windows默认控制台– 命令提示符 :
Next, choose the default behavior of the git pull. We should use the default behavior as fast-forward or merge the branch:
接下来,选择git pull的默认行为。 我们应该将默认行为用作快进或合并分支:
In the next step, Configure the extra options it enables by default. It enables the following features.
在下一步中, 配置默认情况下启用的其他选项 。 它启用以下功能。
- Enable file system caching 启用文件系统缓存
- Enable Git credential manager 启用Git凭证管理器
The configuration for the Git is complete, click on Install in the next page:
Git的配置已完成,单击下一页中的Install:
It starts installing the Git software on your system:
它开始在您的系统上安装Git软件:
You get the following screen once the setup is complete. We can launch the Git Bash from this page in case we put a tick on the checkbox:
设置完成后,将显示以下屏幕。 如果在复选框中打勾,我们可以从此页面启动Git Bash:
We need to add the Git directory in the Windows environment variables as well. Open the system properties -> Advanced -> Environment Variables -> Path:
我们还需要在Windows环境变量中添加Git目录。 打开系统属性-> 高级 -> 环境 变量 -> 路径 :
Now, we can verify the Git installation from the command prompt. Type git in the command prompt and you get output in terms of its syntax, usage:
现在,我们可以从命令提示符下验证Git的安装。 在命令提示符下键入git,您将获得有关其语法,用法的输出:
We require a profile with an email id and user name for the Git. For this, we use the git config command.
我们需要一个配置文件,其中包含Git的电子邮件ID和用户名。 为此,我们使用git config命令。
- >git config –global user.email “rajendra.gupta16@gmail” > git config –global user.email“ rajendra.gupta16@gmail”
- >git config –global user.name “RajendraGupta” > git config –global user.name“ RajendraGupta”
在Azure Data Studio中连接Git (Connect Git in the Azure Data Studio)
Once we installed the Git in the local system, relaunch the ADS and navigate to the Source Control. Here, you see it shows two options.
在本地系统中安装Git之后,重新启动ADS并导航到Source Control。 在这里,您看到它显示了两个选项。
- Open Folder 打开文件夹
- Clone Repository 克隆存储库
First, we need to create a folder that will contain the database scripts for source control. Create a folder in any directory, go to open the folder, and specify the folder path.
首先,我们需要创建一个文件夹,其中将包含用于源代码管理的数据库脚本。 在任何目录中创建一个文件夹,打开文件夹,然后指定文件夹路径。
You can also open the folder from the Azure Data Studio menu as File -> Open Folder:
您还可以从Azure Data Studio菜单中打开该文件夹,方法为文件 -> 打开文件夹 :
It opens the folder, and you can see the folder name in the title bar. I specified the folder name as “GitHub” so it shows it in the title bar as per the following screenshot:
它将打开文件夹,您可以在标题栏中看到文件夹名称。 我将文件夹名称指定为“ GitHub”,以便按照以下屏幕截图将其显示在标题栏中:
Now, go back to source control and click on Initialize Repository:
现在,返回源代码管理并单击“ 初始化存储库”:
You can see the source control as Git in the following image:
您可以在下图中看到源控件为Git:
在Git存储库中添加SQL脚本 (Add a SQL Script in the Git Repository)
For the demonstration purpose, expand the AdventureWorks sample database and script the highlighted view using the option Script as Create:
出于演示目的,展开AdventureWorks示例数据库,并使用选项Script as Create选项对突出显示的视图进行脚本编写:
It generates the script in a new query window of Azure Data Studio:
它在Azure Data Studio的新查询窗口中生成脚本:
Save this script in the Git repository folder we created earlier. You can Press Ctrl+S to save this script or go to File -> Save As option:
将此脚本保存在我们先前创建的Git存储库文件夹中。 您可以按Ctrl + S保存此脚本,或转到文件 -> 另存为选项:
You can see the saved SQL script in the GitHub folder:
您可以在GitHub文件夹中看到保存SQL脚本:
In the source control menu, you can see this SQL script. It currently shows 1 issue in the existing file along with the U mark that defines the Untracked object:
在源代码管理菜单中,您可以看到此SQL脚本。 当前,它在现有文件中显示1个问题以及定义Untracked对象的U标记:
As we have scripted an existing object in the [AdventureWorks] database, it shows the error message. Let’s rename the view name in the generated script and save it.
当我们在[AdventureWorks]数据库中编写了一个现有对象的脚本时,它会显示错误消息。 让我们在生成的脚本中重命名视图名称并保存。
You can see it removes the error message because it is not a duplicate object now:
您可以看到它删除了错误消息,因为它现在不是重复的对象:
Now, click on the Commit(tick icon) to commit the changes in the source control:
现在,单击Commit(勾选图标)以在源控件中提交更改:
Click on Yes to automatically stage all changes and commit them directly into the source control:
单击“ 是”以自动暂存所有更改并将其直接提交到源代码管理中:
It asks for a commit message. It is a custom message that you can put for your reference purpose. By default, it commits on the master branch in the Git:
它要求提交消息。 这是一条自定义消息,您可以将其用作参考。 默认情况下,它在Git中的master分支上提交:
For my reference, I highlighted the message that it modifies the view name:
供我参考,我突出显示了它修改视图名称的消息:
Once you commit changes, it removes the corresponding messages from the source control:
提交更改后,它将从源控件中删除相应的消息:
从Azure Data Studio中的源代码管理编辑现有文件 (Edit an existing file from the source control in Azure Data Studio)
In this section, we will modify an existing SQL script in the Git source control. Click on the script in the GitHub folder, and it opens the script in the new query window.
在本节中,我们将在Git源代码管理中修改现有SQL脚本。 单击GitHub文件夹中的脚本,它将在新的查询窗口中打开脚本。
For the demo, we remove the highlighted columns from the view definition and save the script:
对于该演示,我们从视图定义中删除突出显示的列并保存脚本:
Right-click on the script in the open editor window and click on Compare with Saved:
在打开的编辑器窗口中右键单击脚本,然后单击“ 与保存的比较”:
It compares the original script and the modified script. You can see the difference in the below screenshot. In the left hand, we have the original script with all columns and right-side, it shows a modified script that removes a few columns from the select statement:
它比较原始脚本和修改后的脚本。 您可以在下面的屏幕截图中看到差异。 左侧是原始脚本,其中所有列都在右侧,它显示了修改后的脚本,该脚本从select语句中删除了几列:
In the below screenshot, it shows that integrated view script is modified. You can also see the different color of the text highlighting it is a modified script:
在下面的屏幕截图中,它显示了集成视图脚本已被修改。 您还可以看到不同颜色的文本,突出显示它是经过修改的脚本:
Commit the changes by specifying a commit message. I specified the message that the modified script removes a few columns from the select statement:
通过指定提交消息来提交更改。 我指定了以下消息:修改后的脚本从select语句中删除了几列:
It saves the changes in source control:
它将更改保存在源代码管理中:
查看脚本修改的时间表 (View the timelines of script modifications)
In the source control, go down and expand the timeline folder. Here, you see two commits for my SQL script along with the last commit hr.
在源代码管理中,向下展开时间轴文件夹。 在这里,您将看到我SQL脚本的两次提交以及最后一次提交hr。
- First commit – Modify view name: We committed the SQL script after modified the view name 首次提交–修改视图名称:修改视图名称后,我们提交了SQL脚本
- Commit- Remove a few columns from select: We committed SQL script again after removing a few columns from the select
- 提交- 从选择中删除几列:在从选择中删除几列后,我们再次提交了SQL脚本
Click on the Commit- Remove few columns from select, and you can see the changes we did in the SQL script for this commit:
单击提交- 从选择中删除几列,然后 您可以看到我们在SQL脚本中对此提交所做的更改:
Similarly, you can make multiple changes to SQL script and commit the scripts for different versions. You can view previous changes anytime after the modifications as well.
同样,您可以对SQL脚本进行多项更改,并提交不同版本的脚本。 修改后,您也可以随时查看以前的更改。
结论 (Conclusion)
In this article, we explored the useful Source control Git for SQL Scripts in the Azure Data Studio. You can put multiple versions for SQL script, compare the changes at a later date.
在本文中,我们探索了Azure Data Studio中用于SQL脚本的有用的源代码控件Git。 您可以为SQL脚本放置多个版本,以后再比较更改。
I will cover more topics on the Git Source control for ADS in the upcoming articles. We will also link the local repository with the GitHub to have centralized source control.
在接下来的文章中,我将介绍有关ADS的Git Source控件的更多主题。 我们还将链接本地存储库与GitHub,以进行集中的源代码控制。
目录 (Table of contents)
The SQL Server Assessment Extension for Azure Data Studio |
Source Control using Git in Azure Data Studio (ADS) |
Integrating Azure Data Studio with Git and GitHub |
Working with Git components in Azure Data Studio |
适用于Azure Data StudioSQL Server评估扩展 |
在Azure Data Studio(ADS)中使用Git进行源代码控制 |
将Azure Data Studio与Git和GitHub集成 |
在Azure Data Studio中使用Git组件 |
翻译自: https://www.sqlshack/source-control-using-git-in-azure-data-studio-ads/
mac azure git
版权声明:本文标题:mac azure git_在Azure Data Studio(ADS)中使用Git进行源代码控制 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1726434852h960018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论