A better grasp of Git

by

in

Preface: This was mostly written out nearly 10 months prior to being published.

For some time I have been trying to better understand how Git works and how to not really break things when working with it. The biggest reason being that I really have come to like using it. If I could use it on the daily that would be super amazing as well.

I don’t always get that chance but when I do I really have to dive deep in to see what makes it work and sometimes why it does the things it does. Of course I have to search for things too since there are some things I still don’t fully understand. The good part being that because of trying to solve some things at work I have learned a lot more about the version control system. The part I know takes people back a little bit is when I tell them I began reading the documentation, or rather reading the book that is on the site.

I really did start reading it because I do want to get better at git and really want to understand how it works under the hood. That’s what I did with MySQL as well. I picked up a book and read about how things worked internally. I did gain new knowledge because of it too.

The thing I’ve been working on lately has been those sub-commands that come with git. Some of those are really cool and some can be very destructive if you don’t know what you’re doing of course. I sort of learned that one when I was first starting to work with Git too. A lot of it was just copy and paste things to get things to work.

Over the last two years I’ve learned a lot from reading the docs and some of the comments left in those commands I copied over. It really has been great learning what those commands actually do and a lot of that has been retained too so that’s shocking to me.

I think I realized that a few weeks back when I was dealing with a very large repository.

The story sort of began at work since that’s where I saw this question being raised. The site had a very large footprint on the server. It was 3.1G and part of that was because they had a plugin that created a backup of the site. This took me some time to fully grasp because I didn’t completely understand how Git does the magic it does and it really does do some crazy magic to keep things as compact as possible too.

I searched and found a few posts on cleaning up large repositories and clearing up some git history as well but they didn’t totally click until I tried to run the commands and then read the documentation on those. Yes, I read documentation on commands. I do like doing that when I can and will be doing that more often now as I start diving into shell scripting as well. I do find it fun to read those.

The part that really stood out most was in how things get saved inside of Git. It’s super crazy and cool at the same time. That was when a lot of the things started to make sense in why the git repository was so large as well. Things slowly started to click in my little brain.

I do know that there are still many things I don’t quite understand inside of git but I can for certain say that I am more than willing to learn about it. One of these days I’ll write more about those things I learn along the way. I just need to purchase a few more books and read more of the underlying code.