mac azure git_将Azure Data Studio与Git和GitHub集成

mac azure git

In the last article, Source Control using Git in Azure Data Studio (ADS), we explored the following topics:

在上一篇文章“ 在Azure Data Studio(ADS)中使用Git进行源代码控制”中 ,我们探讨了以下主题:

  • The requirement of Source control for SQL scripts

    SQL脚本的源代码管理要求
  • Git installation on Windows

    Windows上的Git安装
  • Integrate Git in Azure Data Studio

    在Azure Data Studio中集成Git
  • Create Git repository, add SQL scripts, modify files, commit into source control

    创建Git存储库,添加SQL脚本,修改文件,提交到源代码管理
  • View different versions using the Git timelines

    使用Git时间线查看不同版本

In this article, we will take a step forward and integrate Git installed locally on the GitHub.

在本文中,我们将向前迈出一步,并集成在GitHub上本地安装的Git。

First, it is essential to understand the difference between Git and GitHub terminology.

首先,必须了解Git和GitHub术语之间的区别。

Git和GitHub的区别
(The difference in the Git and GitHub
)

Git

GitHub

Git version control is installed locally on your system.

In the previous article, we installed it locally and configured

It is a cloud-based hosting to store your scripts with different versions, repositories.

Git is primarily useful for version control and codeshare

It is a centralized source code sharing platform

It is an open-sourced licensed and provides a command-line interface

Github includes a free tier, pay as you go account as well. We get a graphical interface for GitHub

In Github, we have a centralized platform in which you can create repositories among users, and they can work on it simultaneously. By default, it provides public access for your repository, but you can modify it to a private mode as well

吉特

的GitHub

Git版本控制已本地安装在您的系统上。

在上一篇文章中,我们在本地安装并配置了

它是基于云的托管,用于存储具有不同版本和存储库的脚本。

Git主要用于版本控制和代码共享

这是一个集中的源代码共享平台

它是开放源代码的许可,并提供命令行界面

Github包括免费套餐,随用随付帐户也是如此。 我们获得了GitHub的图形界面

在Github中,我们有一个集中式平台,您可以在其中创建用户之间的存储库,他们可以同时在其上工作。 默认情况下,它为您的存储库提供公共访问权限,但您也可以将其修改为私有模式

If your team has many developers, each of them needs to install Git software locally. You can push and pull changes from their systems, but it becomes slightly complicated as the number of users grows. In the following image, it shows two separate users with Git installed on their systems. Now, both users can push and pull their changes.

Git demo

如果您的团队有很多开发人员,那么每个开发人员都需要在本地安装Git软件。 您可以从他们的系统中推送和拉取更改,但是随着用户数量的增加,更改变得有些复杂。 在下图中,它显示了两个单独的用户,他们的系统上安装了Git。 现在,两个用户都可以推拉他们的更改。

GitHub is a cloud-based web hosting repository. Users can connect to it and begin storing, retrieving the codes.

GitHub是基于云的虚拟主机存储库。 用户可以连接到它并开始存储并检索代码。

GitHub integration

Azure Data Studio中的Git和GitHub集成
(Git and GitHub integration in Azure Data Studio
)

In the above section, we discussed the differences in Git and GitHub. You can integrate these two tools to utilize the benefits of both local resources as well as a cloud solution. You can create a free account in the GitHub and create the repository. Developers can clone their repository from the Git into the GitHub.

在上一节中,我们讨论了Git和GitHub的区别。 您可以集成这两个工具,以利用本地资源和云解决方案的优势。 您可以在GitHub中创建一个免费帐户并创建存储库。 开发人员可以将其存储库从Git复制到GitHub。

First, open the URL https://github.com/ and click on Sign Up.

首先,打开URL https://github.com/ ,然后单击“注册”。

GitHub URL

Provide the required inputs such as username, email address, password, and verify the account.

提供所需的输入,例如用户名,电子邮件地址,密码,并验证帐户。

Enter the basic details

After you create a free GitHub account, create a repository name. By default, it is a public repository so everyone can see the repository, but as a repository owner, we can choose who can commit their changes.

创建免费的GitHub帐户后,创建存储库名称。 默认情况下,它是一个公共存储库,因此每个人都可以看到该存储库,但是作为存储库所有者,我们可以选择谁可以提交其更改。

创建一个GitHub仓库
(Create a GitHub Repository
)

In the below screenshot, we see two parts for repository:

在下面的屏幕截图中,我们看到了存储库的两个部分:

  • Owner: It is the user name we created during signup for the GitHub account

    所有者:这是我们在注册期间为GitHub帐户创建的用户名
  • Repository Name: It is the folder created to store the code

    存储库名称:这是创建用来存储代码的文件夹

GitHub Repository

Click on Create repository. It gives you a web URL that we use to integrate Git in Azure Data Studio with the GitHub.

单击创建存储库。 它为您提供了一个Web URL,我们将其用于将Azure Data Studio中的Git与GitHub集成。

It also gives you instructions to create the repository from the command line. We will explore the git command later.

它还为您提供了从命令行创建存储库的说明。 稍后我们将探讨git命令。

Repository URL

使用Azure Data Studio集成GitHub和Git
(Integrate GitHub and Git using Azure Data Studio
)

Now, launch the ADS and navigate to View-> Command Palette and look for the Git Add Remote.

现在,启动ADS并导航到View-> Command Palette,然后查找Git Add Remote

Integrate GitHub and Git using Azure Data Studio

It opens a pop-up window that asks for the remote name. You can give it any user-friendly name. In the ADS output, you can view the Git commands it uses for its commands. For example, it uses git remote command for this purpose. You can also enable Git: Show Git Output to view git commands it executes in the background.

它会打开一个弹出窗口,要求输入远程名称。 您可以给它提供任何用户友好的名称。 在ADS输出中,您可以查看其命令使用的Git命令。 例如,为此使用git remote命令。 您还可以启用Git:显示Git输出以查看它在后台执行的git命令。

Remote name

After you specify a remote name, press enter, it asks for the URL. We need to specify the GitHub repository that we created earlier.

指定远程名称后,按Enter键,将要求输入URL。 我们需要指定我们之前创建的GitHub存储库。

GitHub repository URL

We do not get any confirmation message that it added the remote URL. No error means everything is fine. However, you can view in the git output that it adds the URL we specified in the GUI.

我们没有收到确认它添加了远程URL的任何确认消息。 没有错误就表示一切都很好。 但是,您可以在git输出中查看它添加了我们在GUI中指定的URL。

Git remote command

Git和GitHub存储库之间的同步
(Synchronization between Git and GitHub repositories
)

Now, let’s remove the earlier file and add a new SQL script without any version. You can follow the previous article and commit a SQL script. In the timeline, we can see that custom message specified by us.

现在,让我们删除先前的文件并添加一个没有任何版本的新SQL脚本。 您可以按照上一篇文章并提交SQL脚本。 在时间轴上,我们可以看到我们指定的自定义消息。

Synchronization between Git and GitHub repositories

At this point, we have prepared the following things:

至此,我们准备了以下内容:

  • Added a GitHub remote URL in the Git configuration of Azure Data Studio

    在Azure Data Studio的Git配置中添加了GitHub远程URL
  • Created a SQL script and committed it in the source control

    创建一个SQL脚本并将其提交到源代码管理中

Now, we have the requirement to sync this local repository of Git into the remote repository of GitHub.

现在,我们需要将Git的本地存储库同步到GitHub的远程存储库中。

To do so, navigate to View-> Command Palette-> Git Sync.

为此,请导航至“视图”->“命令面板”->“ Git同步”。

Command Palette

It starts the synchronization process between the local repository and remote GitHub. We have not specified any explicit branch, so I use the master branch in the GitHub. Click on OK in the below action pop-up.

它开始本地存储库和远程GitHub之间的同步过程。 我们没有指定任何显式分支,因此我在GitHub中使用master分支。 在以下操作弹出窗口中单击“ 确定 ”。

Click Ok

It uses a git pull command for the master branch. It also shows you the list of scripts that it starts synchronizing.

它对master分支使用git pull命令。 它还显示了开始同步的脚本列表。

Git pull command

Now, refresh the web browser for GitHub. In my case, I have two repositories in GitHub. After the synchronization, you can see that Repository ‘RajendraScripts’ shows a t-SQL icon. It shows that this repository has got the SQL script.

现在,刷新GitHub的Web浏览器。 就我而言,我在GitHub中有两个存储库。 同步后,您可以看到存储库“ RajendraScripts”显示一个t-SQL图标。 它表明此存储库已获得SQL脚本。

Multiple repository

Open this repository, and it shows the SQL script file that we have in Git Source. It also shows the message we used that we specified during commit the script in the source control.

打开此存储库,它显示了我们在Git Source中拥有SQL脚本文件。 它还显示了在源代码管理中提交脚本期间指定的消息。

View script in GitHUb

Now, click on the file name to view the SQL script.

现在,单击文件名以查看SQL脚本。

View script content

Can we edit the file in the GitHub and sync it back to the Git repository? Let’s check it out. Click on the highlighted edit icon in the above image to make changes in the code. It opens the script editor. In the below script, I added a few database names, as shown below.

我们可以在GitHub中编辑文件并将其同步回Git存储库吗? 让我们来看看。 单击上图中高亮显示的编辑图标,以对代码进行更改。 它打开脚本编辑器。 在下面的脚本中,我添加了一些数据库名称,如下所示。

Bidirectional sync

Scroll down the page, and you see a section for Commit changes. It automatically gives you a suggestion to put the comment. In my case, it shows comment as Update sys.databases.sql

comment

向下滚动页面,您会看到“提交更改”部分。 它会自动为您提供建议以发表评论。 就我而言,它将注释显示为Update sys.databases.sql

I added the comment Update Script – Add Master, Model, and MSDB database. It suggests that the summary should be less than 50 characters. We can put the extra characters in the description field.

我添加了注释更新脚本–添加主数据库,模型数据库和MSDB数据库 。 建议摘要应少于50个字符。 我们可以在说明字段中放入多余的字符。

Commit message

Let’s modify the comment and put some details in the description box as shown below.

Commit summary and description

让我们修改注释并将一些详细信息放在描述框中,如下所示。

For the commit, we got two options. We can either commit directly to the master branch or create a new branch for this commit in GitHub. Let’s go with the first option and commit to the master branch only.

对于提交,我们有两个选择。 我们可以直接提交到master分支,也可以在GitHub中为此提交创建一个新分支。 让我们选择第一个选项,仅提交到master分支。

Click on Commit Changes. It commits our script changes, and you can see the latest script version along with the script commit summary.

单击提交更改。 它提交了我们的脚本更改,您可以看到最新的脚本版本以及脚本提交摘要。

Commit Changes

Click on the history, and it gives you script versions to commit records. We can see it has two commits as of now.

单击历史记录,它会为您提供脚本版本以提交记录。 到目前为止,我们可以看到它有两次提交。

  • The First commit – It synchronized the script from the Git repository 第一次提交 –它同步了Git存储库中的脚本
  • The second commit– We modified the script in the GitHub editor and committed it to the master branch 第二次提交 –我们在GitHub编辑器中修改了脚本并将其提交到master分支

Script modify and commit

Now, switch to Azure Data Studio and sync the source control again using the Git sync option in the command palette. It reflects the script changes performed in the GitHub for the local repository as well. In the logs, you can see it performed the sync from the GitHub repository URL.

现在,切换到Azure Data Studio并使用命令面板中的Git sync选项再次同步源控件。 它也反映了在GitHub中为本地存储库执行的脚本更改。 在日志中,您可以看到它从GitHub存储库URL执行了同步。

Azure Data Studio Git sync from GItHub

You can click on the script name in the GitHub folder, and it has the latest script.

您可以单击GitHub文件夹中的脚本名称,它具有最新的脚本。

Git timeline

在GitHub中创建脚本版本并在Azure Data Studio的Git存储库中进行同步
(Create a Script Version in the GitHub and sync in the Git repository of Azure Data Studio
)

Let’s create another version of the script. This time we will add an additional script (highlighted below) using the ADS Git repository.

让我们创建脚本的另一个版本。 这次,我们将使用ADS Git存储库添加一个附加脚本(在下面突出显示)。

Create a Script Version

We need to commit each time it needs to be saved into the source control. As we already know, it uses Git Commit to save changes in the script.

每当需要将其保存到源代码管理中时,我们都需要提交。 众所周知,它使用Git Commit将更改保存在脚本中。

Git Commit

Give a suitable name for the commit. Ideally, this commit message should reflect the changes performed in a few words.

给提交一个合适的名字。 理想情况下,此提交消息应该用几句话反映出所做的更改。

put commit message

You got the commit message in the Git timeline after the commit is done.

提交完成后,您会在Git时间轴中收到提交消息。

Git timeline

Perform manual sync between Git and GitHub repositories, and you can see the latest code being checked in.

在Git和GitHub存储库之间执行手动同步,您可以看到正在签入的最新代码。

View latest code

Click on the commit message. You can see the changes in a script in a friendly interactive editor. It shows the plus (+) symbol for the lines we added in the script. Similarly, if we remove any lines, you see it with a minus (-) symbol.

单击提交消息。 您可以在友好的交互式编辑器中查看脚本中的更改。 它显示了我们在脚本中添加的行的加号(+)。 同样,如果我们删除任何行,则会看到带有减号(-)的行。

Plus and minus symbols

对GitHub提交的评论
(Comments on the GitHub commit
)

GitHub provides additional functionality for the users to put their comments on the scripts. Suppose your team member reviewed the script. He can put a comment on the script. Open the script version and put a comment on it, as shown below. Put a comment and click on the Comment on this commit.

GitHub为用户提供了附加功能,可将其评论添加到脚本中。 假设您的团队成员检查了脚本。 他可以对脚本发表评论。 打开脚本版本,并对其进行注释,如下所示。 提出评论,然后单击此提交评论。

Comments on the GitHub commit

It saves the comment for the corresponding commit, as shown below.

它将保存相应提交的注释,如下所示。

View comment

Other users can view the comment, reply to the comment, or use smileys as well. Click on the smiley icon and choose the appropriate smiley to showcase your reaction to the comment.

其他用户可以查看评论,回复评论或使用笑脸。 单击笑脸图标并选择适当的笑脸以展示您对评论的React。

Pick your reaction

We see the reaction on the comment in the following image.

我们在下图中看到对评论的React。

View reaction

结论 (Conclusion)

In this article, we explored the integration of Git and GitHub repository with Azure Data Studio. GitHub is a web-based cloud hosting, and you can sync your local repositories into it. It is bidirectional sync that means you can modify the script either in Git or in GitHub console, and changes reflect in the other repository. We will explore more on the source control in Azure Data Studio in my upcoming articles. Stay tuned!

在本文中,我们探讨了Git和GitHub存储库与Azure Data Studio的集成。 GitHub是一个基于Web的云托管,您可以将本地存储库同步到其中。 这是双向同步,这意味着您可以在Git或GitHub控制台中修改脚本,并且更改会反映在其他存储库中。 我们将在我的后续文章中探索有关Azure Data Studio中的源代码控制的更多信息。 敬请关注!

目录 (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.com/integrating-azure-data-studio-with-git-and-github/

mac azure git

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值