Getting Started with GitHub for SQL Server Developers

By:   |   Comments   |   Related: > DevOps


Problem

What is GitHub and how GitHub can help SQL Server developers? In this tip we will show you the basics on how you can use GitHub for your SQL Server database development.

Solution

Git is an open source distributed source code management system. GitHub is a platform designed based on Git. GitHub offers many features that increase development productivity. An organization can use GitHub to maintain source code or to manage software projects. In addition, community projects also can be done effectively in GitHub. GitHub offers features such as bug tracking, feature requests, task management and wikis pages to increase the communication and collaboration among the team members. GitHub is a popular destination for community projects, because it is easier to integrate developer code with other community members.

GitHub features

  1. The issue tracking tool in the GitHub offers an easy way to manage the projects
  2. Members can share code review comments using GitHub. This promotes collaboration and increases communication.
  3. Mail notifications
  4. Wiki pages style documentation
  5. Data visualization
  6. Subscribe / Watch facility based a denotation

Advantages of GitHub

  1. It is very easy to integrate with open source projects, as most of the open source projects are hosted in GitHub
  2. Low level access controls for team members
  3. Works with all major CI tools
  4. Various tools and plugins are available for tight integration with other CI (Continuous Integration) tools and Visual studio to increase the developer productivity.
  5. Ideal for geographically distributed development teams
  6. Support for command line operations

Licensing Options

  1. GitHub.com - An individual or small team can make use of GitHub.com for personal or community purposes. The source code will be in public domain.
  2. GitHub Enterprise - It is suitable for medium and large-scale enterprises. This option will allow the organization to host GitHub securely on premises.
  3. Private Cloud - It is also possible to host the GitHub in AWS (Amazon Web Service), Azure or in Google cloud platform.

Points to ponder

Repository

A repository is a place where all source code and documents are managed for a project.

Issues

GitHub Issues helps to consolidate the business requirements associated with a change and fixes. This increases the collaboration and communication, as all the dependent information persists in one place. It is highly suitable for teams practicing Agile for development. Wiki GitHub has a wiki style project documentation to store all the business requirements.

Branch

The production source code will be maintained in the "Master" branch. A new branch will be created from the "Master" branch. All the changes associated with a project will be done in this branch. This will help the team to test the changes on the isolated branch. After the successful completion of the testing the new branch will be merged with the "Master" branch. After this the new branch will become obsolete and can be removed. The new branch will be live for the duration of the project to support the development and enhancement.

Pull Request

A pull request indicates the readiness of source code for review. Once the pull request has been created, you can share and review the changes with administrators and commit before the changes are merged into the "Master" branch If you use the keyword "Closes" immediately followed by the issue number, the issue will be closed automatically once the pull request has been merged.

Merging pull request

The merge function will integrate the newly created branch to the "Master" branch. The administrator will have overall visibility and be able to review the code and will be able merge with the master branch. If they are not happy, they can hold the newly submitted change.

Using Code Review

GitHub has a utility to do the code review for the changes committed to a branch. A reviewer can view and approve the change.

Commits

Commit save all the changes to GitHub (Server) since the last commit. A developer can leave appropriate comments during commit. Usually the comment describes the nature and purpose of the change.

GitHub Pages

A GitHub page will allow the developer to create static webpages. In addition, html pages can also be generated from the comments in the source code. GitHub pages can be created by creating a branch with the name "gh-pages." The static html pages and images can be uploaded into this repository.

GitHub Registration

You have to register with GitHub.com to make use of GitHub. GitHub has many pricing models based on your need. All different plans can be found here. With the enterprise solution you can host GitHub within your organization.

GitHub for SQL Developers

I assume that you have registered with GitHub.com. Now in this tip, we will be using Visual Studio to create a database project and check-in the code into GitHub.com.

GitHub Plugin for Visual Studio

Now let's see, how we can work with GitHub using Visual Studio. Visual Studio has a plug-in to work with GitHub directly.  You can search for the "GitHub Extension for Visual Studio" in the Extension and updates menu. Once found, you can download and install the extension. You may need to close Visual Studio in order to complete the installation.

GitHub Extenion for Visual Studio

Once successfully installed, you can start Visual Studio. Now you will be able to see GitHub under the menu "Team Explorer" which is available next to the solution explorer.

GitHub Start up page for Visual Studio

You can then click on the "connect" link to login into GitHub.com. You can then provide your credentials and login into GitHub.com.

GitHub Login page to supply credentials

Once you logged in, you will be able to see the GitHub menu under "Team Explorer" as mentioned in the below picture. As a first step, we need to create a repository with GitHub. This can be done by clicking on the "Create" link.

Create a new repository with GitHub

On the "Create a GitHub Repository" page, provide the Name and the description of the repository. Optionally you can also change the "Local path". Once done, click on the "Create" link to create a new repository.

Supply name and description of the repository

Once the repository has been created, you will see the solution explorer with the newly created repository and the readme.md file, as shown the picture below.

View the repo in the solution explorer

Creating new solution under the new repository

We have successfully created a new repository. Now we need to create a solution within this repository. Let's access the menu "Team Explorer". Under the "Solutions" menu you can click on the "Create" link to create a solution.

Create a solution under the new repo

Our aim is to create a new database project. Hence let's select the "SQL Server" template on the "New Project" window. In addition, you can supply the Solution Name, Project Name and the folder location.

Supply the name of solution and the project

This will create a new solution and the solution can be seen in the solution explorer as mentioned in the picture below.

Solution has been created in the repo

Now we need to add a table to this database project. This can be done by right clicking on the solution name and accessing the menu "Add" & "Table" as shown in the below picture.

Adding new table in the solution

On the "Add new item" window, you can select "Tables and Views" and supply the name of the table.

Supply the name of the table

The table schema can be prepared as mentioned in the picture below.

Create a table

Once the table schema has been created, the code can be checked-in to GitHub.com. On the team explorer, you can click on the "Changes" link to check-in your code changes.

Check-in changes to GitHub

This will list out all the available files for check-in. In this case, we have solution file, project file and all the database project files are ready to be checked-in. I recommend you to type in few comments related with the changes in the "Comment" box, as highlighted in the picture below. This will help you and your team to understand what changes have been made for this specific code. You can click on the "Commit All" button to check-in your changes.

Supply comments for the check-in

This will commit the changes to your local repository. To replicate your changes to the GitHub server, you need to synchronize. This can be done by clicking on "Sync" link in the team explorer.

Changes check-in successfully

After synchronizing the changes, you can see the changes are waiting in the "Outgoing Commits". Your comments about your changes will help you to easily identify the relevant change. If you prefer you can choose to push only a few changes to GitHub.com. You can select a change and click on the link "Push" to save the changes to GitHub.com.

Push the changes to GitHub

Depending on the internet connection and the volume of code, you will see the progress of the Push in the "Team Explorer" as shown in the below screen.

Changes have been pushed into GitHub

Now all the changes have been successfully pushed into GitHub.com.

Changes checked-in to GitHub

Now let's access GitHub.com and browse the repositories. I can see the newly created repository "MSSQLTips".

Repositories in GitHub

Under the repository "MSSQLTips", we can see the solution "Staging" that we have checked-in to GitHub.

Newly created repo in GitHub

Under the "Staging" folder we can see all the solution & project files.

Solution files are available in GitHub

In addition, we can also see the actual code checked-in under the new repository.

View the actual code in GitHub

Summary

In this tip we have learned about GitHub basics and learned to install and setup GitHub extension for Visual Studio. In addition, we have managed to checked-in a sample database solution to GitHub.com.

Next Steps
  • Read more about GitHub here.
  • From "Hello World" to "Guide Book", you can access many step by step documentation for GitHub here.
  • For video learning, you can access cool GitHub videos here.


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Nat Sundar Nat Sundar is working as an independent SQL BI consultant in the UK with a Bachelors Degree in Engineering.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article

















get free sql tips
agree to terms