DBAs, Give Git a Try – Getting Started

One of the really interesting things over the last decade is both the rise of Git as the main VCS system for most projects, and the number of people who know nothing about it. Many of the latter seem intimidated, which is both interesting and strange to me. I usually think of technologies as ready to experiment, but I find more and more they only experiment in narrow boundaries.

This post outlines a quick way to get started with Git.

This is part of my series on git that is designed to help people get started using version control in their daily work. You can see all my other posts on Git as well.

Installation

Got to git.scm.org and download git for your platform. This is an easy install, and you should be able to follow the instructions. For Windows, this is a standard install. You might need to restart any CMD windows to get git in the path.

If you’re on a corporate managed laptop, make sure you verify with your IT group this is allowed. That’s a good practice to get into for any software as anything you add increases your attack surface area. It’s another thing to patch and manage. I’d also document that process for yourself (and your blog).  Do so in a way that doesn’t expose corporate info, please.

Tracking Code

Once you’ve installed Git, what do you do with it? Well, the easy thing to do is start tracking and versioning SQL scripts for most of us. If you’re a DBA/sysadmin/Ops person, you likely are often writing and editing scripts for your job. Let’s track those.

First, if you use SSMS, you often end up storing lots of code in C:\Users\%user_name%\Documents\SQL Server Management Studio. Let’s change that. In your Documents folder (C:\Users\way0u\Documents\ for me), create a “Git” folder. That gives me an organized places for repos.

2024-01-30 11_25_03

Now, let’s create a folder under here for storing my random scripts. Don’t worry about being perfect here, just get started. So, I’ll make an “SSMS” folder. The easy way to do this is open a CMD window and navigate to Git. Then run “mkdir ssms” here. You can see me doing this below.

2024-01-30 11_26_28

You can do this from Explorer (right click, new folder), but practicing the CLI is a good skill. Plus, we will need the CLI below.

Once in this folder, run “git init” to make this a Git repository. This starts tracking files. You can see this below, as well as my copy of the files in the SQL Server Management Studio folder. That might be easier to do with the Explorer GUI, but knowing how to navigate is a skill as well. See my ..\.. as a way to move around folders.

2024-01-30 11_27_20

I only have one file there because, well, most of my work is tracked in Git. I’m actually sad I have even one file here. In any case, I now have files in this folder (I made up a few more).

What I want to do is start tracking these. If I run a “git status”, I see this:

2024-01-30 11_34_26

I see my three .sql files as untracked. This just means Git won’t manage these for now. I need to “add” them. I can do this with “git add <filename” for each one (learn how to use the tab key here), or I can just use “git add –all”. I usually do that since often I want to grab all changes.

Once I do that, I’ll run status, and you can see them as tracked, but not committed. For non-color blind people the filenames changed from red above to green below.

2024-01-30 11_35_56

Now I can commit this and stamp a version. It’s a good idea when you think the file is changed to commit them. Not on every save, but once I think the file is changed the way I want it. For admin scripts, I usually commit once whatever I’m working on is changed appropriately, which might mean I close a ticket or a client says what I did was correct.

You can run git commit, which will open a default editor. For me, I often use the CLI and do a git commit -m “message”  for the commit. The “message” is why you changed something. Here, I’ll just note this is the first commit.

When I run status, it says nothing to commit, meaning no changed files.

2024-01-30 11_38_50

Now as I save scripts, I’ll run through the “git add –all”/”git commit -m message” flow each time I make changes.

One last thing to do.

Fixing SSMS

The last thing is to configure SSMS to save random scripts here. To do this, go into the options and then pick Projects and Solutions and then Locations. You can see this below with the top location set to the original folder where my script was located.

2024-01-30 11_30_39

I want to change that to my repo. Browse or edit the path.

2024-01-30 11_30_51

Now when I create and save random scripts, they’ll go into my repo.

That’s it.

Summary

This showed how to get started saving your random scripts into a git repo. Over time, you might want to organize things better, especially for project or app work, but for now, this will track your scripts over time.

In future posts, I’ll go over these topics to help you get better with working on these scripts.

  • Using VSCode to manage your repo
  • Seeing history and recovering previous versions of scripts
  • Sharing scripts with others

If there are other things you don’t understand or want to learn, please leave a comment below and I’ll answer (and write a post).

Posted in Blog | Tagged , , | 4 Comments

Mind Over Milkshake (Thoughts Matter)

Last year I went to THAT Conference in Wisconsin. It was a fun event, very community and family-friendly, and I enjoyed it. So much so that I recently went back to the Texas event in January. It’s more developer-focused, but it does have some data related sessions. I recommend this conference if you’re looking for some fun training and want to combine that with a family vacation. Your kids will love it.

In any case, I watched a keynote talk that referenced an NPR article, called Mind over Milkshake. It’s an interesting look at how the food labels affected people’s bodies. It’s not definitive and I wouldn’t make any drastic changes based on this, but it is an interesting read on the idea your mind and thoughts can influence your body. I’ve heard about the effect of placebos in the past, we well as attitude on healing, so this makes some sense.

I don’t know to what extent this would change how I manage my health and medical care, but I do think a similar idea is important in my work with databases. I see lots of people who have a negative attitude towards learning, change, or even adopting new/better ways of doing things. So many people, whether workers or management, get stuck in a rut and want to stay there. Or they don’t feel empowered to change. It’s why I find the cultural part of DevOps way more challenging in organizations than the technology part.

In some of my management positions, I’ve often challenged workers not to bring problems, but to find solutions. I want them to view the issues we face, the things that go wrong, as opportunities to improve, not set-in-stone problems that we gripe about. I know many chronic issues recur regularly. I also know that in any organization, there can be resistance to change, and a “we’ve always done it that way” attitude. However, adopting that for yourself is how things continue to linger on (or get worse).

Your mindset can make a huge difference in how you approach situations, including how much stress you feel from the environment. I don’t advocate change for change’s sake, but I do look to critically evaluate if something works well or can be improved. I’ve also learned to ask for change and that being turned down doesn’t mean that nothing changes. Or nothing ever well, or even this thing won’t change. It often means that this particular thing can’t change, or that it can’t change now. I have also learned to separate this request from another request for a different change. The key is often to analyze the solution, prepare a good reason why something should change, and present this un-emotionally.

I know when I approach things as an opportunity life is better. Even if I don’t make a difference, or I don’t like the outcome, I feel better about it. Try it, and you might feel the same way.

Steve Jones

Listen to the podcast at Libsyn, Spotify, or iTunes.

Posted in Editorial | Tagged | Comments Off on Mind Over Milkshake (Thoughts Matter)

Architecting Zero Downtime Deployments at THAT Conference

Thanks to everyone that came to my talk at THAT Conference.

The deck is here, if you want to download it and use it as a resource, or to present internally to your team.

The repo is here: https://github.com/way0utwest/ZeroDowntime

Posted in Blog | Tagged , , , | Comments Off on Architecting Zero Downtime Deployments at THAT Conference

Off to THAT Conference

I’m in Round Rock, TX today at THAT Conference. I attended THAT Conference in Wisconsin Dells last summer, and it was fun. I took my wife, but I wish I’d have known about the event when my kids were younger, as I’ve had taken them.

This is more a developer focused event, but there are a few data sessions, and it’s a good atmosphere. I’ll take pictures and post a review of the conference for those of you that have never heard of it.

Posted in Blog | Tagged , , | 1 Comment