Git and Github: A Love Story or Something Like That.
By: Robert M Ricci
Tags: Programming, Informational, Git, Software Engineering, Github

Github Repo

As I continue my journey to becoming a software engineer, I’m trying to identify gaps in my knowledge. Basic things that I should probably know. As I research them I plan to write a post, which I feel is a good way of retaining the knowledge that I have acquired. Towards the end of my time at the Flatiron School, it occurred to me that this thing that I had basically been using the whole time was still a mystery. I knew how to fork and clone something, I knew how to initialize (or init) a repo, and add files and save them. I just didn't know the why’s or the how’s. I didn't really know what Git even was, and I barely knew about Github.

So that’s what I’m going to do here. I will discuss what git is, and why we use it. Then I will give some info about Github, history, who owns it, and why people seem to prefer it to other options. Then I plan to dive into some popular git commands. I will link all the resources I pulled from in case you want more info. So sit back and relax, it's going to be a bumpy road. Actually, it's going to be fine, I’m not sure why I said that.

GIT

To talk about git I first have to discuss version control. What is version control you may ask, and my response is that it is exactly what it sounds like? It’s a system that manages changes to the files you are working on so you can recall a specific version later. There are three different styles to version control and they are local, centralized, and distributed. This link will tell you more info about all three.

Now where does Git fit into all of this. Git is a distributed version contol system. It was created in 2005 by Linus Torvalds, for development with the linex kernal. They had been using Bitkeeper, but a breakdown with the commercial company that developed Bitkeeper ended in them loosing the free-of-charge status. So Linus, who also created linex, decided to create their own DVCS. They would use what they learned fom Bitkeeper and improve upon it. Thus Git was born. If you want a quick giggle read the naming of Git here, I found it humorous.

One of the main differences between Git and other version control systems is the way Git thinks about data. Most systems use delta based version control, where they store the information as a list of file-based changes.

Git on the other hand takes a snapshot of the information and compares it to the existing file and then only saves the differences. If a file hasn't changed then Git just links to the already existing file.

One of the key features to Git and is intergreal to its speed is that everything is local. Since everything has been cloned on to your computer it makes searching a project almost instintanous. Another benefit of this is the ability to work offline, and then pushing commits once you are on network again. Git also uses checksums to store and then refer back to that data. Which makes it impossible to change anything without Git knowing. This helps with not losing data and file corruption.

Git has three stages modified, staged, committed.

Modified: File has been changed, but not saved to the directory.

Staged: File has been marked to be saved.

Commited: File has been saved.

These three stages correlate to the three sections of a Git project the working tree, staging area, and the Git directory.

GITHUB

Github was launched in April 2008 by Tom Preston-Werner, Chris Wanstrath, P. J. Hyett, and Scott Chacon. It reported fairly early success with 46,000 public repositories in the first year. The numbers grew from there with 90,000 repositories and 100,000 users the following year. The numbers just continued to grow, until they caught the attention of Microsoft, which had been using Github since 2012. Micorsoft acquired Github in 2018, for $7.5 billion. Sidenote for my Javascript users out there Microsoft also acquired npm, this year.

So Github is popular, but why. This one is hard to anwser for me. I’ve only ever used it, so I have no reference for how it compares to other version control sites. I can say that as someone just getting started, that it is pretty user friendly, and it has a plethera of features. The community is a huge part of what makes it great. Being able to check out other peoples code, and in return have them look at yours, and give feed back is pretty great. It also has a bunch of integrations and features which just add to its usability. The one feature I currently use is Github Pages, which I use to host my portfolio page.

GIT COMMANDS

I’m going to go over some basic commands for Git, with links to more in-depth explanations. I will be assuming you are using Github to do this. Things you will need to do first is make sure Git is installed, and that you have an account set-up with Github. Also, most if what I’ll be talking about will be for use with MacOs, as that's what I use, but most will be universal. So to install git from the terminal us can use the command:

$ git --version

If you don't have Git it will ask you to install it. Instead of walking you through you first repo, I will just link you to Github guides walkthrough which is very details, with images and everything. I probably couldn’t explain it better than they can. Here are some basic Git commands with links to their documentation:

Here are some commands also with links to documentation that also may prove useful, but you might not need right out of the gate:

git rm — remove files from a working tree.

git mv — move or rename a file.

git checkout — switch branches.

git diff — shows changes between commits.

The last thing I wanted to explain is the Github flow, just so you have an idea of how it works. It has six steps:

Create a branch. Add commits. Open a pull request. Discuss and review code. Merge. Deploy.

CONCLUSSION

I learned so much by researching Git and Github. Not all of it is going to make me a more productive software engineer, but knowing it definitely makes me feel more like one. Having some background knowledge about things more experienced engineeres know, can really help with imposter syndrome. Make you feel like you have a little insight about this world you are trying to become part of. I know I will use all of this knowledge and put it to use, my command line abilities get better everyday, to the point were I don’t have to use the mouse for as much, which makes me that much faster.

I hope you found this helpful. I will split the links to all the resources I used as primary and secondary. That way you will know where the main source of information came from. I would encourage you to check them even if you are only cherry picking them and not reading the whole thing. They provided me with so much knowledge, I can’t even really begin to explain.

PRIMARY RESOURCES

SECONDARY RESOURCES