Git Started

Posted on 31st August 2015

I use Git to manage my work, and you should too. At the very least, Git allows you to keep track of changes, make branches, collaborate with others, and time-travel.

Of course, that's half the fun. GitHub is where the community comes together to create amazing open source projects. GitHub visualises the information that is given by Git, hosts your code, and makes coding social. The source code for this website is available at github.com/mariuszskon/skoneczko.com. Of course, alternatives exists, but GitHub has by far the largest community. This blog post just shows off some features of Git, and is not intended as a guide. At the end of this post, I have included some learning material for those interested.

Why you need to use Git

Keeping track of changes

Git allows you to keep track of changes. Every time you run git commit, Git saves a snapshot of your files, and you can see exactly which lines have changed. This also allows you to time-travel: you can look back at previous states of a file, so if you added some super risky experimental feature, and want to go back to how things were, Git makes it easy.

Branches

A really powerful feature of Git's is branches: you can split up your changes into different branches, and then merge those branches back together. For example, when I am working on my website, I branch off my "testing" branch and call it something descriptive, for example, "gitblogpost". Once I am happy with those changes, I merge them into the "testing" branch, where unstable code sits. Once I am sure that the change is stable, I merge it back into the "master" branch. What makes this great is that you can work on multiple things at once: you can make a separate branch for the blog post, a separate one for some style improvements, and another one to fix some bugs, and then merge them all together. This leads me to my next point.

Collaboration

Of course, collaboration is much easier done with an online host, such as GitHub, Bitbucket or GitLab. Git allows you to push to repositories, and pull changes from them. Since Git already has merging, this means that you can collaborate with people easily: you can work individually, but them automatically merge your changes together. Of course, sometimes things don't merge nicely and you need to resolve them yourself, but usually with good cooperation, you should be fine.

Getting started

If you are convinced and haven't used Git before, I recommend Try Git for a nice tutorial and git - the simple guide as a complementary source of information (and a useful cheat sheet!)