By: Nat Sundar | Updated: 2018-12-20 | Comments | Related: More > DevOps
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.
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.
- The issue tracking tool in the GitHub offers an easy way to manage the projects
- Members can share code review comments using GitHub. This promotes collaboration and increases communication.
- Mail notifications
- Wiki pages style documentation
- Data visualization
- Subscribe / Watch facility based a denotation
Advantages of GitHub
- It is very easy to integrate with open source projects, as most of the open source projects are hosted in GitHub
- Low level access controls for team members
- Works with all major CI tools
- Various tools and plugins are available for tight integration with other CI (Continuous Integration) tools and Visual studio to increase the developer productivity.
- Ideal for geographically distributed development teams
- Support for command line operations
- 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.
- GitHub Enterprise - It is suitable for medium and large-scale enterprises. This option will allow the organization to host GitHub securely on premises.
- Private Cloud - It is also possible to host the GitHub in AWS (Amazon Web Service), Azure or in Google cloud platform.
Points to ponder
A repository is a place where all source code and documents are managed for a project.
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.
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.
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.
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.
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.
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.
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.
You can then click on the "connect" link to login into GitHub.com. You can then provide your credentials and login into GitHub.com.
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.
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.
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.
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.
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.
This will create a new solution and the solution can be seen in the solution explorer as mentioned in the picture below.
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.
On the "Add new item" window, you can select "Tables and Views" and supply the name of the table.
The table schema can be prepared as mentioned in the picture below.
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.
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.
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.
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.
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.
Now all the changes have been successfully pushed into GitHub.com.
Now let's access GitHub.com and browse the repositories. I can see the newly created repository "MSSQLTips".
Under the repository "MSSQLTips", we can see the solution "Staging" that we have checked-in to GitHub.
Under the "Staging" folder we can see all the solution & project files.
In addition, we can also see the actual code checked-in under the new repository.
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.
- 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.
Last Updated: 2018-12-20
About the author
View all my tips