Posted in Source Control, SQL Server

Setting Up Git

I somehow have been using some form of source control for my entire database career. And I’ve been using Git for the past several years at work. I decided to create a repository as another way to make my sessions and scripts accessible and as better way to organize them, rather than just uploading to the SQL Saturday or user group sites and keep them scattered across multiple folders on my computer.

You would think as someone who has used source control regularly, it would be fairly simple to do. When it comes to that someone being me, you would be wrong.

As I was trying to set things up, I would run across a post about how simple it is to do X. So I tried to follow the directions. Then I would spend a couple of hours cursing at my computer wondering why this simple thing isn’t so simple. I think at one point, I may have deleted the files I had uploaded and then spent at least 30 minutes and whole lot of curse words trying to find how I could revert the changes. Did I end up creating pull requests for changes that I – y’know, the owner of the repository – made and then have to approve? Yep – I totally did that. I’m pretty sure it was one of those pull requests that caused me to (temporarily) delete everything in my repository. And here I thought I was actually pretty good at doing code reviews. Good going, Deb!

And now I have to figure out how to handle special versions of the sessions. If I’m doing something specific for a certain presentation or SQL Saturday, do I want to just overwrite my current presentation, create a separate folder or create a branch? But if I create a branch, does this mean I should reorganize things so I’m creating branches just for each project rather than organizing all of my projects together?

Oh, and I have this blog too. Every now and then I may have a script that I want to add to support the work that I’ve done in a post. Uploading these to Git and connecting that directly to the page is a great idea. I have a sample script that I uploaded as a pdf file a while ago. But that’s not the best way to do this. This would be a perfect test for figuring how to set this up. So now I need to decide how I want to organize these files. Do I just throw them into individual folders so I can have READMEs that point to the post it belongs to? I can’t see any reason for needing to branch these files as I make fixes. I don’t care about having to go back to different versions; that’s what the history is for.

Git Log with no rev nos
The log for one of my sessions that I just added to Git using Tortoise Git.

Then the most important question – how do I connect all of this to how I want to work? My first set of changes was logging on to the Github site and just dragging and dropping the files where I wanted them. In the end, I decided to install Tortoise Git because I am familiar and comfortable with how it works. For some reason, I never found myself that comfortable using the command line for Git. So do I need to create a shortcut to learn some of these commands better for the command line or even check out PowerShell modules to see if there’s something there?

Notice how there are more questions and issues rather than solutions. This is because while I have the initial structure set up, I know I need to make changes and adjustments and I don’t have the answers for all of these figured out yet.

All of this is to say that there’s a lot that goes into setting up source control for your purposes. The good news for me is that these are my personal files. I’m not creating a mission critical application with release schedules so if I screw things up and delete everything, it’s still OK. (This also speaks to why it’s probably a good thing that this is my day job.) By going through this process, I better understand and appreciate how important and difficult it is to set up any source control correctly so it does work with how you and\or your company work. The unexpected bonus for me may be that it makes me better at something that I need to do on a regular basis.

I will probably be fussing with how I have my repo set up for a bit, if not constantly. It’s going to be interesting to figure out how this will work best for my needs. Here’s hoping I don’t delete everything … again!

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s